天天看點

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問題的解決

原因:

Spring boot Application沒有掃描到mapper

解決辦法:

主要看架構是用什麼方法配置的,樓主是SpringBoot +Mybaits,倉庫配置加上@MapperScan(annotationClass = Repository.class, basePackages = "com.xxx.dao")

注意上面紅字部分,因為DataConfig中有此注解,要求所有mapper接口也要加此注釋,否則掃描不到,即:

@Repository

pulic interface DailyMapper{

//....省略

}