首先是构造函数,可以通过@PostConstruct注解在方法上标注
然后是各个字段的set方法
然后是实现了InitializingBean接口的方法
最后如果在XML中定义了init-method的方法
在XML中的</bean>元素中有depends-on这个属性,用于告诉spring这个bean初始化前必须先初始化哪些bean.
比如:这个bean实现了InitializingBean接口, 在afterPropertiesSet接口要根据配置初始化一些参数, 但是这个配置需要从configUtil中读取. 这样就要求configUtil必须可用.
1 <bean id="adminAuthorizingRealm" class="XXX.security.AdminAuthorizingRealm" depends-on="configUtil">
Spring文档中的说明:
The depends-on attribute can explicitly force one or more beans to be initialized before the bean using this element is initialized.
详细说明可以参考spring的reference.