spring注入时报错::No qualifying bean of type 'xxx.xxMapper'


 

做一个小项目,因为有 baseService,所以偷懒就没有写单独的每个xxService接口,直接写的xxServiceImpl,结果在service实现类中注入Mapper的时候,用的 @Autowired,

结果,junit一启动,就报错误:Java.lang.illegalStateException:Failed to load ApplicationContext

具体是在 创建bean的时候报:No qualifying bean of type 'xxx.xxMapper' abailable:expected at least 1 bean which qualifies as autowire candidate.......

错误,

经过百度即测试,发现解决方法是:

在@Autowired 注解下面加上@Qualifier(“xxxxxMapper”)注解


免责声明!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系本站邮箱yoyou2525@163.com删除。



 
粤ICP备18138465号  © 2018-2025 CODEPRJ.COM