spring-boot 应用 报错 No qualifying bean of type XXXXX.***Mapper

报错类型

NoSuchBeanDefinitionException、No qualifying bean of type  XXXXX.***Mapper

报错信息详情

Caused by: org.springframework.beans.factory.NoSuchBeanDefinitionException: No qualifying bean of type 'com.pflm.modules.job.dao.ScheduleJobMapper' available: expected at least 1 bean which qualifies as autowire candidate. Dependency annotations: {@javax.annotation.Resource(shareable=true, lookup=, name=, description=, authenticationType=CONTAINER, type=class java.lang.Object, mappedName=)}

原因分析

这个错误原因是由于@Mapper注解 mapper文件 没有被扫描到 所以报错,NoSuchBeanDefinitionException,bean 未定义,找不到该 bean

解决方法:

在 spring-boot 应用的程序入口 加上 @MapperScan("指定mapper的包名,指定mapper的包名2") 即可解决问题

原文地址:https://www.cnblogs.com/geekswg/p/13081365.html