I have the following scenario:
class A with "bean-a" in wireup.xml
class B extends A with "bean-b" in wireup.xml
Since B is also A, which means there are more than one instance of class A in application context.
I want to uniquely identify the singleton instance of class B, so I used
@Qualifier("unique_name") in class B
and
<qualifier value="unique_name"/> in "bean-b" of wireup.xml
But the issue is still there, I get message as :
No unique bean of type [A] is defined: expected single matching bean but found 2: [A, B]
How do I resolve this?
Thank you
The @Qualifier should not be put in classB. Instead it should be put along with autowired.
Your class should look like,
By this means you are telling autowire the b with of type B (type B or A because B is subclass of A) but with a bean definition which has the qualifier “unique_name”. The wireup.xml has the qualifier tag assigned to bean-b. Your wireup.xml might look like this