1. 实现org.springframework.beans.factory.InitializingBean接口,可以注册bean.
public class AnotherExampleBean implements InitializingBean { public void afterPropertiesSet() { // do some initialization work } }
1.1 实现org.springframework.beans.factory.DisposableBean接口,可以在bean销毁前执行某些操作.
public class AnotherExampleBean implements DisposableBean { public void destroy() { // do some destruction work (like releasing pooled connections) } }
2. 实现ApplicationContextAware 或者 BeanNameAware 接口.
3. 其他Ware接口