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

2019 年 7 月 3 日
 cway

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)} 实在不知道哪里错了,求助大家帮搜搜

6692 次点击
所在节点    Java
11 条回复
dovme
2019 年 7 月 3 日
forecastServiceImpl 加 @Service 注解了吗?
fooving
2019 年 7 月 3 日
baseMapper 是接口吧?
是不是在 forecastServiceImpl 有
@autowire
baseMapper

?接口是不能 autowire 的
tudouxiong
2019 年 7 月 3 日
上 stackoverflow 求助 ✘
上 V2EX 求助 ✔
wc951
2019 年 7 月 3 日
这和 mybatis 有什么关系,这不就是 spring 注入失败了吗
cway
2019 年 7 月 3 日
@dovme 都加了,Mapper 中也加了 @Mapper 注解

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

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

发现个奇怪的问题,我用 SpringBoot 用之前代码没问题,,但是我换成普通 lib 中放 jar 形式的项目就不行,同样的代码。
jinue9900
2019 年 7 月 3 日
@cway 你不是一个 maven 工程么,要么可能有 starter 要么就是配置没配好
cluulzz
2019 年 7 月 3 日
MotherShip
2019 年 7 月 4 日
这是 Mybatis Plus 把
你说 SBoot 可以 SSM 不行,估计是少了什么 starter 中的配置,没配包扫描之类的。。
cway
2019 年 7 月 5 日
@jinue9900 明显不是,是导 jar 包的 ssm 工程,虽然落后了点但是只能这样
@MotherShip 所以不知道什么问题呀
hafuhafu
2019 年 7 月 9 日
入口类上加注解 @MapperScan(mapper 包名)
大概
lavvrence
2019 年 7 月 19 日
BaseMapper 打上 @Repository 或者 @Mapper 看看

这是一个专为移动设备优化的页面(即为了让你能够在 Google 搜索结果里秒开这个页面),如果你希望参与 V2EX 社区的讨论,你可以继续到 V2EX 上打开本讨论主题的完整版本。

https://study.congcong.us/t/579507

V2EX 是创意工作者们的社区,是一个分享自己正在做的有趣事物、交流想法,可以遇见新朋友甚至新机会的地方。

V2EX is a community of developers, designers and creative people.

© 2021 V2EX