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

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

Consider defining a bean of type 'XX.XX.XX.XX.mapper.XXMapper' in your configuration.的更多相关文章

  1. Consider defining a bean of type 'org.springframework.data.redis.connection.RedisConnectionFactory' in your configuration

    Description: Parameter 0 of method redisTemplate in com.liaojie.cloud.auth.server.config.redis.Redis ...

  2. 【spring boot】mybatis启动报错:Consider defining a bean of type 'com.newhope.interview.dao.UserMapper' in your configuration. 【Mapper类不能被找到】@Mapper 和@MapperScan注解的区别

    启动报错: 2018-05-16 17:22:58.161 ERROR 4080 --- Disconnected from the target VM, address: '127.0.0.1:50 ...

  3. Spring Boot:Consider defining a bean of type '*.*.*' in your configuration解决方案

    果然不看教程直接使用在遇到问题会懵逼,连解决问题都得搜半天还不一定能帮你解决了... ***************************APPLICATION FAILED TO START*** ...

  4. Consider defining a bean of type 'com.lvjing.dao.DeviceStatusMapper' in your configuration.

    "C:\Program Files\Java\jdk1.8.0_181\bin\java.exe" "-javaagent:C:\Program Files\JetBra ...

  5. springboot 工程启动报错之Consider defining a bean of type ‘XXX’ in your configuration.

    一.前言: 使用springboot自动注入的方式搭建好了工程,结果启动的时候报错了!!!,错误如下图: Description: Field userEntityMapper in com.xxx. ...

  6. 关于spring boot自动注入出现Consider defining a bean of type 'xxx' in your configuration问题解决方案

    搭建完spring boot的demo后自然要实现自动注入来体现spring ioc的便利了,但是我在实施过程中出现了这么一个问题,见下面,这里找到解决办法记录下来,供遇到同样的问题的同僚参考 Des ...

  7. 记一个SpringBoot中属性注入失败的问题Consider defining a bean of type ''' in your configuration

    今天遇到的一个问题: 代码检查了好几次,都没有错误,但是启动时就会报错Consider defining a bean of type ''' in your configuration. 启动类在c ...

  8. Consider defining a bean of type 'package' in your configuration [Spring-Boot]

    https://stackoverflow.com/questions/40384056/consider-defining-a-bean-of-type-package-in-your-config ...

  9. Spring Cloud ZooKeeper集成Feign的坑1,错误:Consider defining a bean of type 'org.springframework.web.client.RestTemplate' in your configuration.

    错误如下: ERROR 31473 --- [ main] o.s.b.d.LoggingFailureAnalysisReporter : *************************** A ...

随机推荐

  1. Java工具类使用注意事项

    (以下摘自阿里巴巴Java开发手册) 1. [强制]获取单例对象需要保证线程安全,其中的方法也要保证线程安全. 说明:资源驱动类.工具类.单例工厂类都需要注意. 5. [强制]SimpleDateFo ...

  2. MyEclipse 2014 有用的几个快捷键

    ctrl+h  fileSearch ------------------------------------- MyEclipse 快捷键1(CTRL) ---------------------- ...

  3. redis_1 安装和简单使用

    前言: mysql 数据库:数据以“文件形式存储在硬盘”里面.硬盘的存取速度很慢.数据库是一个系统中最占用资源的部分.当sql语句比较复杂(关联的表比较多的时候),每执行一次就会消耗大量的资源.倘若一 ...

  4. ACdream 1415 Important Roads

    Important Roads Special JudgeTime Limit: 20000/10000MS (Java/Others)Memory Limit: 128000/64000KB (Ja ...

  5. HDU2147 kiki's game

    /* HDU2147 kiki's game 博弈论 巴什博奕 http://acm.hdu.edu.cn/showproblem.php?pid=2147 题意:在一个n×m的棋盘上,初始棋子放在右 ...

  6. HDU 4355

    只能说感觉是三分吧,因为两端值肯定是最大的,而中间肯定存在一点使之最小,呃,,,,猜 的... #include <iostream> #include <cstdio> #i ...

  7. [React Router] Create a ProtectedRoute Component in React Router (setState callback to force update)

    In this lesson we'll create a protected route just for logged in users. We'll combine a Route with a ...

  8. 【LeetCode-面试算法经典-Java实现】【056-Merge Intervals(区间合并)】

    [056-Merge Intervals(区间合并)] [LeetCode-面试算法经典-Java实现][全部题目文件夹索引] 原题 Given a collection of intervals, ...

  9. iOS_21团购_地图功能

    终于效果图: 右下角的回到用户位置button: MapController控制器, 是主控制器左側dock上面的[地图]button相应的控制器, 继承自ShowDealDetailControll ...

  10. VMWare虚拟机下为Ubuntu 12.04.1网络设置(NAT方式)

    NAT方式: 虚拟机能够上外网,能够訪问宿主计算机所在网络的其它计算机(反之不行). 第一步:设置虚拟机vmware网络參数 (1)打开虚拟机,选择菜单"编辑">" ...