spring-boot跟整合mapper出现如下错误,盼望高手解答

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了spring-boot跟整合mapper出现如下错误,盼望高手解答相关的知识,希望对你有一定的参考价值。

2017-12-24 17:42:09,615:WARN main (AbstractApplicationContext.java:551) - Exception encountered during context initialization - cancelling refresh attempt: org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'userController': Unsatisfied dependency expressed through field 'userService'; nested exception is org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'userServiceImpl': Unsatisfied dependency expressed through field 'userMapper'; nested exception is org.springframework.beans.factory.NoSuchBeanDefinitionException: No qualifying bean of type 'com.yichao.yichaoadmin.mapper.user.UserMapper' available: expected at least 1 bean which qualifies as autowire candidate. Dependency annotations: @org.springframework.beans.factory.annotation.Autowired(required=true)
2017-12-24 17:42:09,616:WARN main (DisposableBeanAdapter.java:374) - Invocation of destroy method 'close' failed on bean with name 'sqlSessionTemplate': java.lang.UnsupportedOperationException: Manual close is not allowed over a Spring managed SqlSession
2017-12-24 17:42:09,618:INFO main (DirectJDKLog.java:179) - Stopping service [Tomcat]
2017-12-24 17:42:09,637:INFO main (AutoConfigurationReportLoggingInitializer.java:101) -

Error starting ApplicationContext. To display the auto-configuration report re-run your application with 'debug' enabled.
2017-12-24 17:42:09,711:ERROR main (LoggingFailureAnalysisReporter.java:42) -

***************************
APPLICATION FAILED TO START
***************************

Description:

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

Action:

Consider defining a bean of type 'com.yichao.yichaoadmin.mapper.user.UserMapper' in your configuration.

Disconnected from the target VM, address: '127.0.0.1:61973', transport: 'socket'

参考技术A mybatis没有配置对,没有正常注入mapper的bean 参考技术B

主要是这句异常:No qualifying bean of type 'com.yichao.yichaoadmin.mapper.user.UserMapper'

    mapper注入有误,就是在业务逻辑层的注入有问题

    mapper没有被spring管理起来,看看是否被扫描到了

以上是关于spring-boot跟整合mapper出现如下错误,盼望高手解答的主要内容,如果未能解决你的问题,请参考以下文章

实践丨SpringBoot整合Mybatis-Plus项目存在Mapper时报错

实践丨SpringBoot整合Mybatis-Plus项目存在Mapper时报错

SpringBoot整合Mybatis进行单元测试mapper和xml路径不一致出现的诡异问题

spring-boot整合freemarker 出现404

spring-boot整合freemarker 出现404

Spring整合Mybatis遇到的问题