Consider defining a bean of type 'XX.XX.XX.XX.mapper.XXMapper' in your configuration.
2024-09-30 06:25:04
今天构建一个springboot 项目,采用mybatis+mysql 然后就出现了这种错误....浪费我半天时间
Description: Field loginLogMapper in com.guoll.modules.sysmanage.service.PassagewayService required a bean of type 'com.guoll.modules.sysmanage.mapper.LoginLogMapper' that could not be found. The injection point has the following annotations:
- @org.springframework.beans.factory.annotation.Autowired(required=true) Action: Consider defining a bean of type 'com.guoll.modules.sysmanage.mapper.LoginLogMapper' in your configuration. Process finished with exit code 0
错误原因:是由于springboot 扫描不到 mapper
解决方案:
第一种:在mapper包下类配置@Mapper 注解
第二种:在springboot 启动类上配置包扫描@ComponentScan()
第三种:在springboot 启动类上配置Mapper扫描@MapperScan(注意:必须将路径指定到 xxx.xxx.xxx.mapper 包为止,否则依旧扫描不到) 多个mapper路径 可以以 @MapperScan({mapper1路径,mapper2路径})
这种本人亲测
第四种解决方法,就是将 spring boot启动类方法mapper上级,这样也可以扫描到
工作中出了问题,解决时间太久,记录一下
最新文章
- oracle遇到的锁异常,oralce record is locked by another user
- greenDao:操作数据库的开源框架
- 【Android】YUV使用总结 —— Android常用的几种格式:NV21/NV12/YV12/YUV420P的区别
- Array数组标准库
- [Arduino] 基于Xbee Pro和网络技术的智能公交系统设计
- VC 对话框背景颜色、控件颜色(三种方法)
- 用NodeJS创建一个聊天服务器
- ORA-00904:标识符无效
- [LeetCode] Find Smallest Letter Greater Than Target 找比目标值大的最小字母
- Android仿淘宝购物车demo
- python select.select模块通信全过程详解
- opencart3图片Google Merchant Center验证通过不了的解决方法
- 封装Thread的两种方法 via C++ in Linux
- SQL 服务器 - RDBMS
- <;a>;<;/a>;标签传参出现乱码问题
- SQL assistant
- 2013年6月编程语言排行榜,C语言位据第一位
- 从Table 表中取出第 m 条到第 n 条的记录
- smtp自动发送邮件demo
- wifi设置