Hello Friend:
It is murky to me asking to Spring Team about the beans imported in a ApplicationContext with same name or id .
I have one ApplicationContext.xml that import a other ApplicationContext file called ApplicationContextB.xml
In the file ApplicationContextB.xml I have putCode:<import resource="ApplicationContextB.xml"> <bean id="classA" class="ClassA" destroy-method="close"> <property name="aString" value="ClassAFirst"/> </bean />
Now, when execute my Application Sample, that work fine (it executed without any exceptions even its does repeated the name.).Code:<bean id="classA" class="ClassA" destroy-method="close"> <property name="aString" value="ClassALast"/> </bean />
But, when I get a bean with name "ClassA", Spring got me a last bean rather than a first bean.
How Can I know that? After got a bean, I print the content of the beanīs property "aString", that show the message "ClassALast".
Itīs stranger true?
It seens that Spring always the last bean founded (in case of they use the same ID or name) when import other beans from other applicationContext.xml
Spring do it for any reason? or It... , in worst case, is a Bug?![]()
Thanks in advance.


Reply With Quote
