V2EX = way to explore
V2EX 是一个关于分享和探索的地方
Sign Up Now
For Existing Member  Sign In
cway
V2EX  ›  Java

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

  •  
  •   cway · Jul 3, 2019 · 6691 views
    This topic created in 2495 days ago, the information mentioned may be changed or developed.

    org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'forecastServiceImpl': Injection of autowired dependencies failed; nested exception is org.springframework.beans.factory.BeanCreationException: 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 replies    2019-07-19 09:57:18 +08:00
    dovme
        1
    dovme  
       Jul 3, 2019
    forecastServiceImpl 加 @Service 注解了吗?
    fooving
        2
    fooving  
       Jul 3, 2019
    baseMapper 是接口吧?
    是不是在 forecastServiceImpl 有
    @autowire
    baseMapper

    ?接口是不能 autowire 的
    tudouxiong
        3
    tudouxiong  
       Jul 3, 2019 via Android   ❤️ 1
    上 stackoverflow 求助 ✘
    上 V2EX 求助 ✔
    wc951
        4
    wc951  
       Jul 3, 2019 via Android
    这和 mybatis 有什么关系,这不就是 spring 注入失败了吗
    cway
        5
    cway  
    OP
       Jul 3, 2019
    @dovme 都加了,Mapper 中也加了 @Mapper 注解

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

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

    发现个奇怪的问题,我用 SpringBoot 用之前代码没问题,,但是我换成普通 lib 中放 jar 形式的项目就不行,同样的代码。
    jinue9900
        6
    jinue9900  
       Jul 3, 2019
    @cway 你不是一个 maven 工程么,要么可能有 starter 要么就是配置没配好
    cluulzz
        7
    cluulzz  
       Jul 3, 2019
    MotherShip
        8
    MotherShip  
       Jul 4, 2019
    这是 Mybatis Plus 把
    你说 SBoot 可以 SSM 不行,估计是少了什么 starter 中的配置,没配包扫描之类的。。
    cway
        9
    cway  
    OP
       Jul 5, 2019
    @jinue9900 明显不是,是导 jar 包的 ssm 工程,虽然落后了点但是只能这样
    @MotherShip 所以不知道什么问题呀
    hafuhafu
        10
    hafuhafu  
       Jul 9, 2019
    入口类上加注解 @MapperScan(mapper 包名)
    大概
    lavvrence
        11
    lavvrence  
       Jul 19, 2019
    BaseMapper 打上 @Repository 或者 @Mapper 看看
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Solana   ·   886 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 53ms · UTC 18:52 · PVG 02:52 · LAX 11:52 · JFK 14:52
    ♥ Do have faith in what you're doing.