一、问题

springboot项目启动时报错:

Field userMapper in com.example.springbootdruid.service.impl.UserServiceImpl required a bean of type 'com.example.springbootdruid.mapper.UserMapper' that could not be found.

原因是因为没有扫描到对应的类

二、解决方式:

1、检查配置文件是否写对:

  在springboot的配置文件添加,mybatis的配置如下所示:

mybatis:
type-aliases-package: com.xxx.xxx.domain
mapper-locations: classpath:/mybatis/*.xml

2、是否加上相应的注解

  在启动类上加上@MapperScan或者@ComponentScan注解,手动指定application类要扫描哪些包下的注解,如下所示:

@SpringBootApplication
@MappertScan(basePackages = {"com.xxx.xxx.mapper"})

  或者在接口上添加@Mapper注解。

@Mapper
public interface UserMapper {
}

注意检查涉及到的包路径是否写正确。

springboot 启动报错Consider defining a bean of type 'com.example.springbootdruid.mapper.UserMapper' in your configurati的更多相关文章

  1. spring cloud gateway网关启动报错:No qualifying bean of type 'org.springframework.web.reactive.DispatcherHandler'

    网关配置好后启动报错如下: org.springframework.context.ApplicationContextException: Unable to start web server; n ...

  2. IntelliJ IDEA 2017版 spring-boot 报错Consider defining a bean of type 'xxx' in your configuration问题解决方案

    问题分析: 通过问题的英文可知,这个错误是service的bean注入失败,那么为什么会产生这个问题呢? 主要是框架的Application产生的,所以我们建立项目的时候,要保证项目中的类跟Appli ...

  3. springboot 启动报错"No bean named 'org.springframework.context.annotation.ConfigurationClassPostProcessor.importRegistry' available"

    1.问题 springboot启动报错 "D:\Program Files\Java\jdk-11\bin\java.exe" -XX:TieredStopAtLevel=1 -n ...

  4. SpringBoot启动报错:ould not be registered. A bean with that name has already been defined in file and overriding is disabled.

    SpringBoot启动报错 ***************************APPLICATION FAILED TO START*************************** Des ...

  5. SpringBoot启动报错Failed to determine a suitable driver class

    SpringBoot启动报错如下 Error starting ApplicationContext. To display the conditions report re-run your app ...

  6. Caused by: org.springframework.beans.factory.NoSuchBeanDefinitionException: No qualifying bean of type 'com.qingmu.mybaitsplus.mapper.UserMapper' available:

    java.lang.IllegalStateException: Failed to load ApplicationContext at org.springframework.test.conte ...

  7. 【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 ...

  8. 2. springboot启动报错:Field userMapper in com.service.UserService required a bean of type 'com.dao.UserMapper' that could not be found.

    报错信息: 2018-06-25 14:26:17.103  WARN 49752 --- [  restartedMain] ationConfigEmbeddedWebApplicationCon ...

  9. springboot启动报错start bean 'eurekaAutoServiceRegistration' NullPointerException

    解决方案参考:https://blog.csdn.net/hhj13978064496/article/details/82825365 我将eureka的依赖包放到了依赖包的最下面,启动报错, 如下 ...

随机推荐

  1. Python--编码与字符串

    为什么字符串要编码呢? 因为计算机只能处理数字,最底层的CPU只能识别0和1.所以字符串就需要编码成对应的数字. 在计算机中,最开始只有ASCII,我们开始接触计算机编程时就学了ASCII码.最早只有 ...

  2. java程序员学习路线阶段总结20190903

    算法:锻炼写代码的逻辑 刷题位置:leetcode 书籍:小灰漫画算法 leecode使用方法: 转载自http://blog.csdn.net/tostq 又到了一年毕业就业季了,三年前的校招季我逃 ...

  3. 简单的 Python 人脸识别实例

    案例一 导入图片 思路: 1.导入库 2.加载图片 3.创建窗口 4.显示图片 5.暂停窗口 6.关闭窗口 # 1.导入库 import cv2 # 2.加载图片 img = cv2.imread(' ...

  4. JMeter使用代理进行录制

    参考: http://www.cnblogs.com/zhuque/archive/2012/11/13/2767747.html JMeter支持第三方(Badboy)录制和代理录制,Badboy录 ...

  5. 模板汇总——splay

    #define lch(x) tr[x].son[0] #define rch(x) tr[x].son[1] ; , root; struct Node{ ], pre, sz; void init ...

  6. CF991C Candies 二分 第十五

    Candies time limit per test 1 second memory limit per test 256 megabytes input standard input output ...

  7. yzoj P2349 取数 题解

    题意 1到n个自然数中选k个自然数要求两两不相邻,问有多少种方法,模m eg(1 3 5 ) 又是一道打表规律题,正常解法dp可以通过前缀和优化到O(N* K).另外我们可以重新定义F[I,J]表示从 ...

  8. 为什么使用消息队列?消息队列有什么优点和缺点?Kafka、ActiveMQ、RabbitMQ、RocketMQ 都有什么优点和缺点?

    面试题 为什么使用消息队列? 消息队列有什么优点和缺点? Kafka.ActiveMQ.RabbitMQ.RocketMQ 都有什么区别,以及适合哪些场景? 面试官心理分析 其实面试官主要是想看看: ...

  9. python中列表,数字,字符串函数总结

    列表list: arr = [] 1.可以定义空列表 2.可以定义只有一个元素的列表 3.元素可以是任意类型 arr.append('abc')末尾添加 arr.insert(index,objec) ...

  10. 章节十六、7-DataProviders

    一.当我们的同一个test有多套数据需要进行测试,那么我们就需要用到-->DataProviders package testclasses1; import org.testng.annota ...