• Consider defining a bean of type 'XX.XX.XX.XX.mapper.XXMapper' in your configuration.


    今天构建一个springboot 项目,采用mybatis+mysql 然后就出现了这种错误....浪费我半天时间

     1 Description:
     2 
     3 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.
     4 
     5 The injection point has the following annotations:
     6 - @org.springframework.beans.factory.annotation.Autowired(required=true)
     7 
     8 
     9 Action:
    10 
    11 Consider defining a bean of type 'com.guoll.modules.sysmanage.mapper.LoginLogMapper' in your configuration.
    12 
    13 
    14 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上级,这样也可以扫描到

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

  • 相关阅读:
    ElasticSearch安装中遇到的一些问题
    微信扫描二维码下载问题
    nginx截获客户端请求
    Nginx中的一些匹配顺序
    Redis-cli命令最新总结
    RabbitMQ服务安装配置
    Nginx服务状态监控
    使用Sqlserver更新锁防止数据脏读
    PHPStorm IDE 快捷键(MAC)
    MongoDB 安装
  • 原文地址:https://www.cnblogs.com/zhangzhonghui/p/10833743.html
Copyright © 2020-2023  润新知