Java – how to control the order of bean init method in spring?
•
Java
Suppose I have a bean, then I should call the init method or constructor after the init method of another bean Is it possible?
Solution
Use the dependencies on attribute XML file in the spring context:
<bean id="beanOne" class="ExampleBean" depends-on="manager"> <property name="manager"><ref local="manager"/></property> </bean>
Or @ dependso if annotations are used, annotate on the bean
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
二维码