Lets say I import four resource files in my application's main configuration file as below,
<import resource="db-config.xml"/>
<import resource="cache-config.xml"/>
<import resource="sec-config.xml"/>
<import resource="rajnikanth.xml"/>
<!-- My app beans here -->
My understanding is that Spring creates a DAG and instantiate bottom-up. What about the disconnected nodes in the graph? Does order of import come into the play? Please explain.
Yes, order matters. If you declare a bean in one imported file and then declare a bean with the same name in a subsequently imported file, the first bean declaration is overridden.
UPDATE: To more directly address your question, it is fine to have beans in earlier imports refer to beans in later imports. Order does not matter in this way.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With