I am currently going through Mkyong Spring 3.0 tutorial.
He goes on to clarify these 2 basic things.
1. Bean in different XML files
If you are referring to a bean in different XML file, you can reference it with a ‘ref‘ tag, ‘bean‘ attribute.
2. Bean in same XML file
If you are referring to a bean in same XML file, you can reference it with ‘ref‘ tag, ‘local‘ attribute.
The only thing I can make out is that the local attribute
is not supported any more in version 4.1.
5. For the timebeing, I have sticked to the
<ref bean="thebeaninstance"/>
and it works for both. <ref bean="...">
requires only it to be in the same context
, or in a parent context
.
But i am looking for something by which i will be able to resolve the difference once if somehow i encounter same ids in 2 different beans, and wish to refer to the one defined in different XML, since preference goes to the one defines in the same XML. Please suggest.