问题:expected single matching bean but found 2
2017-03-29 17:07
721 查看
问题:
严重: Exception sending context initialized event to listener instance of class org.springframework.web.context.ContextLoaderListener
org.springframework.beans.factory.BeanCreationException: Error creating bean with name ‘queueRemindJob’: Injection of autowired dependencies failed; nested exception is org.springframework.beans.factory.BeanCreationException: Could not autowire field: private com.witontek.ehospital.service.clinic.IQueueRemindService com.witontek.ehospital.job.impl.QueueRemindJob.queueRemindService; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name ‘queueRemindServiceImpl’: Injection of autowired dependencies failed; nested exception is org.springframework.beans.factory.BeanCreationException: Could not autowire field: private com.witontek.ehospital.service.base.ISendTemplateMsgService com.witontek.ehospital.service.clinic.impl.QueueRemindServiceImpl.sendTemplateMsgService; nested exception is org.springframework.beans.factory.NoUniqueBeanDefinitionException: No qualifying bean of type [com.witontek.ehospital.service.base.ISendTemplateMsgService] is defined: expected single matching bean but found 2: sendAlipayTemplateMsgService,sendWechatTemplateMsgService
at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor.postProcessPropertyValues(AutowiredAnnotationBeanPostProcessor.java:292)
at
问题原因:一个接口,被两个类所实现,又被如下注解
修改方法:
成功!
严重: Exception sending context initialized event to listener instance of class org.springframework.web.context.ContextLoaderListener
org.springframework.beans.factory.BeanCreationException: Error creating bean with name ‘queueRemindJob’: Injection of autowired dependencies failed; nested exception is org.springframework.beans.factory.BeanCreationException: Could not autowire field: private com.witontek.ehospital.service.clinic.IQueueRemindService com.witontek.ehospital.job.impl.QueueRemindJob.queueRemindService; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name ‘queueRemindServiceImpl’: Injection of autowired dependencies failed; nested exception is org.springframework.beans.factory.BeanCreationException: Could not autowire field: private com.witontek.ehospital.service.base.ISendTemplateMsgService com.witontek.ehospital.service.clinic.impl.QueueRemindServiceImpl.sendTemplateMsgService; nested exception is org.springframework.beans.factory.NoUniqueBeanDefinitionException: No qualifying bean of type [com.witontek.ehospital.service.base.ISendTemplateMsgService] is defined: expected single matching bean but found 2: sendAlipayTemplateMsgService,sendWechatTemplateMsgService
at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor.postProcessPropertyValues(AutowiredAnnotationBeanPostProcessor.java:292)
at
问题原因:一个接口,被两个类所实现,又被如下注解
@Autowired private ISendMsgService sendMsgService;
修改方法:
@Autowired @Qualifier("sendWeChatMsgService") private ISendMsgService sendWeChatMsgService; @Autowired @Qualifier("sendAPPMsgService") private ISendMsgService sendAPPMsgService;
成功!
相关文章推荐
- spring " expected single matching bean but found 2" 问题一例。
- 在开发自己淘宝客网站配置spring 遇到问题:expected single matching bean but found 2
- spring依赖注入单元测试:expected single matching bean but found 2
- 深入Spring Boot:怎样排查expected single matching bean but found 2的异常
- spring依赖注入单元测试:expected single matching bean but found 2
- 多数据源报错 expected single matching bean but found 2
- Spring的JUnit错误:NoSuchBeanDefinitionException: No unique bean of type,expected single matching bean but found 2 [dataSource1,data
- 深入Spring Boot:怎样排查expected single matching bean but found 2的异常
- expected single matching bean but found 2
- 开发:异常收集之 expected single matching bean but found 2
- expected single matching bean but found 2
- 开发:异常收集之 expected single matching bean but found 2
- spring依赖注入单元测试:expected single matching bean but found 2
- 使用dubbo对外暴露接口,实现类同时实现两个接口后 @Autowire失败,提示expected single matching bean but found 2解决方案
- expected single matching bean but found 2
- expected single matching bean but found 2
- spring注解错误-expected single matching bean but found 2
- expected single matching bean but found 2
- expected single matching bean but found 2 注解继承冲突
- Spring 3.2 @Autowired异常:expected single matching bean but found 2