I have rather different experience.
here is an example
I have person class in my configuration file I have say following bean definitions.
in my code if I put @AutowiredCode:<bean id="person1" class="com.test.Person"/> <bean id="personA" class="za.co.discovery.util.Person"/> <bean id="personB" class="za.co.discovery.util.Person"/> <util:list id="persons"> <ref bean="personA" /> <ref bean="personB" /> </util:list>
All I get in the list personA , personB and surprisingly person1 . with autowired list will give me all the beans person declared inside application context. My List size showing me 3 instead of 2Code:@Autowired List<Person> persons;
if I declare one more list
both list showing me size 5 that means all the person's beans inside xml i.e. 5 instead of 2.Code:<bean id="person1" class="com.test.Person"/> <bean id="personA" class="za.co.discovery.util.Person"/> <bean id="personB" class="za.co.discovery.util.Person"/> <bean id="personC" class="za.co.discovery.util.Person"/> <bean id="personD" class="za.co.discovery.util.Person"/> <util:list id="persons"> <ref bean="personA" /> <ref bean="personB" /> </util:list> <util:list id="persons2"> <ref bean="personC" /> <ref bean="personD" /> </util:list> @Autowired List<Person> persons; @Autowired List<Person> persons2;
but if I do context.getBean("persons") give me size 2 and context.getBean("persons2")
give me size 2 which is proper behavior
is it bug ????
I have tested both spring 2.5.6 and spring 3.1.0.M1 same result.


Reply With Quote