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

2019-07-03 09:59:45 +08:00
 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)} 实在不知道哪里错了,求助大家帮搜搜

5601 次点击
所在节点    Java
11 条回复
dovme
2019-07-03 10:20:00 +08:00
forecastServiceImpl 加 @Service 注解了吗?
fooving
2019-07-03 10:44:51 +08:00
baseMapper 是接口吧?
是不是在 forecastServiceImpl 有
@autowire
baseMapper

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

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

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

发现个奇怪的问题,我用 SpringBoot 用之前代码没问题,,但是我换成普通 lib 中放 jar 形式的项目就不行,同样的代码。
jinue9900
2019-07-03 18:52:23 +08:00
@cway 你不是一个 maven 工程么,要么可能有 starter 要么就是配置没配好
cluulzz
2019-07-03 23:31:54 +08:00
MotherShip
2019-07-04 10:46:27 +08:00
这是 Mybatis Plus 把
你说 SBoot 可以 SSM 不行,估计是少了什么 starter 中的配置,没配包扫描之类的。。
cway
2019-07-05 08:40:42 +08:00
@jinue9900 明显不是,是导 jar 包的 ssm 工程,虽然落后了点但是只能这样
@MotherShip 所以不知道什么问题呀
hafuhafu
2019-07-09 08:22:22 +08:00
入口类上加注解 @MapperScan(mapper 包名)
大概
jaylee4869
2019-07-19 09:57:18 +08:00
BaseMapper 打上 @Repository 或者 @Mapper 看看

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

https://www.v2ex.com/t/579507

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

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

© 2021 V2EX