场景:
多个Module相互依赖,其中的服务模块调用dao模块,出现下面报错。
报错信息如下:
Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'loanApplyController': Injection of resource dependencies failed; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'loanApplyServiceImpl': Injection of resource dependencies failed; nested exception is org.springframework.beans.factory.NoSuchBeanDefinitionException: No qualifying bean of type 'ccx.coop.mapper.LoanApplyInfoMapper' 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=)}
提取关键词:beans.factory.BeanCreationException
出现改异常无非俩个原因:
1、引入资源没有注入到bean工厂;
2、引入资源是否有重名嫌疑。
我的解决方法是:在服务模块启动类增加mapper的接口实现:
@MapperScan("ccx.coop.mapper")