您的位置:首页 > 其它

问题: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

问题原因:一个接口,被两个类所实现,又被如下注解

@Autowired
private ISendMsgService   sendMsgService;


修改方法:

@Autowired
@Qualifier("sendWeChatMsgService")
private ISendMsgService sendWeChatMsgService;

@Autowired
@Qualifier("sendAPPMsgService")
private ISendMsgService sendAPPMsgService;


成功!
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: