异常代码:
No qualifying bean of type 'com.xxxx.dao.DailyMapper' available: expected at least 1 bean which qualifies as autowire candidate. Dependency annotations: {}
如图:

原因:
Spring boot Application没有扫描到mapper
解决办法:
主要看框架是用什么方法配置的,楼主是SpringBoot +Mybaits,仓库配置加上@MapperScan(annotationClass = Repository.class, basePackages = "com.xxx.dao")
注意上面红字部分,因为DataConfig中有此注解,要求所有mapper接口也要加此注释,否则扫描不到,即:
@Repository
pulic interface DailyMapper{
//....省略
}

本文解决了一个常见的Spring Boot与MyBatis集成时遇到的问题:Mapper接口未被正确扫描。通过添加正确的注解配置,确保了Mapper能够被Spring Boot自动装配。

被折叠的 条评论
为什么被折叠?



