@Autowired with @Qualifier dows not work as expected
I have two classes implementing the same interface. I have described them in a xontext xml as 2 beans.
I am using annotations to inject second bean:
<bean id="transporter" class="com.medicum.tns.transport.impl.LiveSOAPMsgTransporterImpl" />
<bean id="devTransporter" class="com.medicum.tns.transport.impl.DevSOAPMsgTransporterImpl"/>
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:
private SOAPMsgTransporter transporter;
What i did wrong?
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]