spring boot+mybatis报错mapper无法注入

搭建spring boot项目时启动出现的问题,先来看异常片段:

Error starting ApplicationContext. To display the conditions report re-run your application with 'debug' enabled.
2019-06-04 09:32:21.462 ERROR 18900 --- [           main] o.s.b.d.LoggingFailureAnalysisReporter   : 
 
***************************
APPLICATION FAILED TO START
***************************
 
Description:
 
Field userMapper in com.drefore.demozw.admin.service.TestOneService required a bean of type 'com.drefore.demozw.mapper.UserMapper' 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.drefore.demozw.mapper.UserMapper' in your configuration.

提示mapper未找到无法注入

在网上搜索了一圈有说项目结构的问题,application入口类应该放在 mapper同级目录下,可是我的目录结构没问题,可能别的地方适用,在我这只好另找办法,最后在application入口类上添加该注解解决问题

@MapperScan("mapper文件夹路径")

spring boot+mybatis报错mapper无法注入

上一篇:delphi xe10 文件目录/路径操作 (Andorid、ios)


下一篇:delphi xe10 手机内部系统相关操作(手机信息、震动、剪贴板、键盘、电话、拨号)