I have classes, xml configuration file and error stack trace like this. I have no idea why @Qualifier doesn\'t work. I see on errors that he don\'t even do anything.
@Qualifier(name="..") annotation and give the name of the bean that we want Spring to inject
and name of your beans are size1 and size2 .
so try
@Qualifier("size1")
@Qualifier is used to reference a bean by its name or id. Since it can't find an xml entry that has a name or id of 'small' it tries to match by type, of which it found two instances of Size.
The following would work:
<bean id="small" class="com.tests.test2.Size">
<property name="height" value="2"/>
<property name="width" value="1"/>
</bean>
Though it appears you would like to treat instances of Size as pre-configured beans. If that were the case you could declare instances of Dog in your xml file and refer to Size beans ... something like this:
<bean id="rex" class="com.tests.test2.SimpleDog">
<property name="name" value="Puppy" />
<property name="size" ref="size1"/>
</bean>