SpringBoot:No qualifying bean of type 'com.xxxx.dao.DailyMapper' available: expected at least 1问题的解决

异常代码:

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

如图:

SpringBoot:No qualifying bean of type 'com.xxxx.dao.DailyMapper' available: expected at least 1问题的解决_第1张图片

 

原因:

Spring boot Application没有扫描到mapper

 

解决办法:

主要看框架是用什么方法配置的,楼主是SpringBoot +Mybaits,仓库配置加上@MapperScan(annotationClass = Repository.class, basePackages = "com.xxx.dao")

注意上面红字部分,因为DataConfig中有此注解,要求所有mapper接口也要加此注释,否则扫描不到,即:

@Repository

pulic interface DailyMapper{

//....省略

}

 

你可能感兴趣的:(spring,java)