mybatis plus 报错求助 百度没百到求助 - V2EX
V2EX = way to explore
V2EX 是一个关于分享和探索的地方
现在注册
已注册用户请  登录
cway
V2EX    Java

mybatis plus 报错求助 百度没百到求助

  •  
  •   cway 2019-07-03 09:59:45 +08:00 6302 次点击
    这是一个创建于 2301 天前的主题,其中的信息可能已经有所发展或是发生改变。

    org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'forecastServiceImpl': Injection of autowired dependencies failed; nested exception is org.springframework.beans.factory.BeanCreationExceptin: Could not autowire field: protected com.baomidou.mybatisplus.mapper.BaseMapper com.baomidou.mybatisplus.service.impl.ServiceImpl.baseMapper; nested exception is org.springframework.beans.factory.NoSuchBeanDefinitionException: No qualifying bean of type [com.baomidou.mybatisplus.mapper.BaseMapper] found for dependency: expected at least 1 bean which qualifies as autowire candidate for this dependency. Dependency annotations: {@org.springframework.beans.factory.annotation.Autowired(required=true)} 实在不知道哪里错了,求助大家帮搜搜

    11 条回复    2019-07-19 09:57:18 +08:00
    dovme
        1
    dovme  
       2019-07-03 10:20:00 +08:00
    forecastServiceImpl 加 @Service 注解了吗?
    fooving
        2
    fooving  
       2019-07-03 10:44:51 +08:00
    baseMapper 是接口吧?
    是不是在 forecastServiceImpl 有
    @autowire
    baseMapper

    ?接口是不能 autowire 的
    tudouxiong
        3
    tudouxiong  
       2019-07-03 11:14:19 +08:00 via Android   1
    上 stackoverflow 求助
    上 V2EX 求助
    wc951
        4
    wc951  
       2019-07-03 14:32:05 +08:00 via Android
    这和 mybatis 有什么关系,这不就是 spring 注入失败了吗
    cway
        5
    cway  
    OP
       2019-07-03 17:18:58 +08:00
    @dovme 都加了,Mapper 中也加了 @Mapper 注解

    @fooving baseMapper 是 mybatis plus 自己的代码吧

    @wc951 就是不知道哪里出错了呀

    发现个奇怪的问题,我用 SpringBoot 用之前代码没问题,,但是我换成普通 lib 中放 jar 形式的项目就不行,同样的代码。
    jinue9900
        6
    jinue9900  
       2019-07-03 18:52:23 +08:00
    @cway 你不是一个 maven 工程么,要么可能有 starter 要么就是配置没配好
    cluulzz
        7
    cluulzz  
       2019-07-03 23:31:54 +08:00
    MotherShip
        8
    MotherShip  
       2019-07-04 10:46:27 +08:00
    这是 Mybatis Plus 把
    你说 SBoot 可以 SSM 不行,估计是少了什么 starter 中的配置,没配包扫描之类的。。
    cway
        9
    cway  
    OP
       2019-07-05 08:40:42 +08:00
    @jinue9900 明显不是,是导 jar 包的 ssm 工程,虽然落后了点但是只能这样
    @MotherShip 所以不知道什么问题呀
    hafuhafu
        10
    hafuhafu  
       2019-07-09 08:22:22 +08:00
    入口类上加注解 @MapperScan(mapper 包名)
    大概
    lavvrence
        11
    lavvrence  
       2019-07-19 09:57:18 +08:00
    BaseMapper 打上 @Repository 或者 @Mapper 看看
    关于     帮助文档     自助推广系统     博客     API     FAQ     Solana     5410 人在线   最高记录 6679       Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 26ms UTC 01:17 PVG 09:17 LAX 18:17 JFK 21:17
    Do have faith in what you're doing.
    ubao msn snddm index pchome yahoo rakuten mypaper meadowduck bidyahoo youbao zxmzxm asda bnvcg cvbfg dfscv mmhjk xxddc yybgb zznbn ccubao uaitu acv GXCV ET GDG YH FG BCVB FJFH CBRE CBC GDG ET54 WRWR RWER WREW WRWER RWER SDG EW SF DSFSF fbbs ubao fhd dfg ewr dg df ewwr ewwr et ruyut utut dfg fgd gdfgt etg dfgt dfgd ert4 gd fgg wr 235 wer3 we vsdf sdf gdf ert xcv sdf rwer hfd dfg cvb rwf afb dfh jgh bmn lgh rty gfds cxv xcv xcs vdas fdf fgd cv sdf tert sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf shasha9178 shasha9178 shasha9178 shasha9178 shasha9178 liflif2 liflif2 liflif2 liflif2 liflif2 liblib3 liblib3 liblib3 liblib3 liblib3 zhazha444 zhazha444 zhazha444 zhazha444 zhazha444 dende5 dende denden denden2 denden21 fenfen9 fenf619 fen619 fenfe9 fe619 sdf sdf sdf sdf sdf zhazh90 zhazh0 zhaa50 zha90 zh590 zho zhoz zhozh zhozho zhozho2 lislis lls95 lili95 lils5 liss9 sdf0ty987 sdft876 sdft9876 sdf09876 sd0t9876 sdf0ty98 sdf0976 sdf0ty986 sdf0ty96 sdf0t76 sdf0876 df0ty98 sf0t876 sd0ty76 sdy76 sdf76 sdf0t76 sdf0ty9 sdf0ty98 sdf0ty987 sdf0ty98 sdf6676 sdf876 sd876 sd876 sdf6 sdf6 sdf9876 sdf0t sdf06 sdf0ty9776 sdf0ty9776 sdf0ty76 sdf8876 sdf0t sd6 sdf06 s688876 sd688 sdf86