Java – the order of bean initialization in spring
•
Java
My spring configuration file has the following beans: @ h_ 419_ 7@
<bean id="myList" class="java.util.ArrayList">
<constructor-arg>
<list>
<ref bean="elem1"/>
<ref bean="elem2"/>
<ref bean="elem3"/>
<ref bean="elem4"/>
</list>
</constructor-arg>
</bean>
<bean id="elem4" class="myClass">
<property name="title" value="random4"/>
</bean>
<bean id="elem1" class="myClass">
<property name="title" value="random1"/>
</bean>
<bean id="elem3" class="myClass">
<property name="title" value="random3"/>
</bean>
<bean id="elem2" class="myClass">
<property name="title" value="random2"/>
</bean>
Solution
Springs do respect the order you give in the list The elements in the list will be exactly the [elem1, elem4] you specified Otherwise, what did you do wrong? Can you display and print the codes of different orders@ H_ 419_ 7@
<bean id="holder" class="my.HolderBean" lazy-init="false"> <property name="inner" ref="inner"/> </bean> <bean id="inner" class="my.InnerBean" lazy-init="false"/>
The content of this article comes from the network collection of netizens. It is used as a learning reference. The copyright belongs to the original author.
THE END
二维码
