今天构建一个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上级,这样也可以扫描到

工作中出了问题,解决时间太久,记录一下

最新文章

  1. oracle遇到的锁异常,oralce record is locked by another user
  2. greenDao:操作数据库的开源框架
  3. 【Android】YUV使用总结 —— Android常用的几种格式:NV21/NV12/YV12/YUV420P的区别
  4. Array数组标准库
  5. [Arduino] 基于Xbee Pro和网络技术的智能公交系统设计
  6. VC 对话框背景颜色、控件颜色(三种方法)
  7. 用NodeJS创建一个聊天服务器
  8. ORA-00904:标识符无效
  9. [LeetCode] Find Smallest Letter Greater Than Target 找比目标值大的最小字母
  10. Android仿淘宝购物车demo
  11. python select.select模块通信全过程详解
  12. opencart3图片Google Merchant Center验证通过不了的解决方法
  13. 封装Thread的两种方法 via C++ in Linux
  14. SQL 服务器 - RDBMS
  15. <a></a>标签传参出现乱码问题
  16. SQL assistant
  17. 2013年6月编程语言排行榜,C语言位据第一位
  18. 从Table 表中取出第 m 条到第 n 条的记录
  19. smtp自动发送邮件demo
  20. wifi设置

热门文章

  1. UVA455 - Periodic Strings(紫书习题3.4)
  2. 51nod-完美字符串(贪心)
  3. OGG For Bigdata To Kafka同步问题处理
  4. hdu5386 Cover
  5. Spring In Action读书笔记
  6. angularjs1-1
  7. 英语发音规则---S字母
  8. 关于HTML与CSS与class
  9. SQL语句之transaction
  10. 当安装了ubuntu操作系统怎么也调用不出中文输入法时,可以用以下方式尝试解决。