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

自作多情 提交于 2019-12-01 03:48:56

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.

Use @DependsOn annotation or depends-on attribute if you're using xml configuration.

You can use de depends-on attribute on your second bean.

Reference: http://static.springsource.org/spring/docs/1.2.x/reference/beans.html#beans-factory-dependson

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!