Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to control order of bean init-method invocation in Spring?

Suppose I have bean, which init-method or constructor should be called after init-method of another bean. Is it possible?

like image 635
Shikarn-O Avatar asked Feb 21 '12 14:02

Shikarn-O


1 Answers

Use depends-on attribute in spring context XML file:

<bean id="beanOne" class="ExampleBean" depends-on="manager">
  <property name="manager"><ref local="manager"/></property>
</bean>

or @DependsOn annotation on bean if you are using annotations.

like image 76
AlexR Avatar answered Oct 19 '22 23:10

AlexR