@Autowired with @Qualifier dows not work as expected
Hi all,
I have two classes implementing the same interface. I have described them in a xontext xml as 2 beans.
Code:
<bean id="transporter" class="com.medicum.tns.transport.impl.LiveSOAPMsgTransporterImpl" />
<bean id="devTransporter" class="com.medicum.tns.transport.impl.DevSOAPMsgTransporterImpl"/>
I am using annotations to inject second bean:
Code:
@Autowired
@Qualifier("devTransporter")
private SOAPMsgTransporter transporter;
I want to inject bean by name, because there are 2 beans implementing the same interface. So I added @Qualifier annotation. It does not work and gives an exception:
Code:
Error creating bean with name 'documentService': Autowiring of fields failed; nested exception is org.springframework.beans.factory.BeanCreationException: Could not autowire field: private com.medicum.tns.transport.SOAPMsgTransporter com.medicum.tns.service.ehealth.DocumentService.transporter; nested exception is org.springframework.beans.factory.NoSuchBeanDefinitionException: No unique bean of type [com.medicum.tns.transport.SOAPMsgTransporter] is defined: expected single matching bean but found 2: [transporter, devTransporter]
What i did wrong?
Thank you.