- 创建对象
- 属性填充
- aware接口的对应方法
- init-method方法(@PostConstruct)
- initialingBean接口的方法
- BeanPostProcessor的前置方法
- BeanPostProcessor的后置方法
- DisposableBean的distory方法
测试对象
@Component
public class TestController implements BeanNameAware,InitializingBean, BeanPostProcessor, DisposableBean {
@Override
public void setBeanName(String s) {
System.out.println("setBeanName "+s);
}
@PostConstruct
public void init() {
System.out.println("init");
// ...
}
@Override
public void afterPropertiesSet() throws Exception {
System.out.println("afterPropertiesSet");
}
@Override
public Object postProcessBeforeInitialization(Object bean, String beanName) throws BeansException {
System.out.println("postProcessBeforeInitialization");
return BeanPostProcessor.super.postProcessBeforeInitialization(bean, beanName);
}
@Override
public Object postProcessAfterInitialization(Object bean, String beanName) throws BeansException {
System.out.println("postProcessAfterInitialization");
return BeanPostProcessor.super.postProcessAfterInitialization(bean, beanName);
}
@Override
public void destroy() throws Exception {
System.out.println("destroy");
}
}
结果
setBeanName testController
init
afterPropertiesSet
postProcessBeforeInitialization
postProcessAfterInitialization
重复出现postProcessBeforeInitialization,postProcessAfterInitialization
destroy
标签:BeanPostProcessor,springboot,System,bean,println,声明,public,out
From: https://www.cnblogs.com/xiuer211/p/17693843.html