本文主要是介绍Spring集成MyBatis问题: No MyBatis mapper was found in '[xx.xx]' package. Please check your configuration,希望对大家解决编程问题提供一定的参考价值,需要的开发者们随着小编来一起学习吧!
问题出现情况
在使用SpringBoot集成MyBatis的过程中,项目正常启动异常,控制台打出如下日志:
No MyBatis mapper was found in ‘[xx.xxx]’ package. Please check your configuration.
Description:
A component required a bean of type ‘xx.xxx.noticess.dao.NewDaoInter’ that could not be found.
Action:
Consider defining a bean of type ‘xx.xxx.noticess.dao.NewDaoInter’ in your configuration.
问题处理
出现问题的几种情形如下几种:
1.对应的Mapper目录写错.
2.少了配置文件.
3.在应用入口类:XxxApplication.java中没有加入@MapperScan(basePackages = {""})注解,
4.application.yml里面没有配置Mybatis的映射路径mapper-locations
5.注解方式不对,可使用@Mapper注解,如果不是springboot项目可用@Repository注解
基本上也就这几种情况了!
这篇关于Spring集成MyBatis问题: No MyBatis mapper was found in '[xx.xx]' package. Please check your configuration的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!