Alex Rivera | Logout

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

Asked 2012-02-21T14:08:06.770
9

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

Edit
Report

1 Answer

14

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.

answered 2012-02-21T14:14:07.143

Your Answer