A solution other than the Qualifier annotation in Spring
===

I have a usecase for which I cannot use the Qualifier annotation (atleast according to my understanding) but I still need to resolve between two beans for Autowire. Here is the setup I have:

    class Foo
    {
        @Autowired
        private FooBar a;
    }

    interface FooBar
    {}

    class FooBarA implements FooBar
    {}

    class FooBarB implements FooBar
    {}

spring config:

    <bean id="beanA" class="FooBarA"/>
    <bean id="beanB" class="FooBarB"/>

    <bean id="bean1" class="Foo">
        <constructor-arg><ref="beanA"/></constructor-arg>
    </bean>

    <bean id="bean2" class="Foo">
        <constructor-arg><ref="beanB"/></constructor-arg>
    </bean>

This throws an error saying it cannot resolve the bean for the variable "a" in class "Foo" because there are two beans (beanA and beanB) even though I have explicitly specified which derivation of FooBar to use in each case of bean1 and bean2.