Spring:Bean生命周期

关于Bean生命周期,我在网上找了两张图:

图1:

图2:

总结起来就是:

Bean构建:

Bean对象创建 》 @Autowired | @Resource | @Inject |@Value》 @PostConstruct 》 InitializingBean#afterPropertiesSet 》 XML(init-method)

Bean 销毁:

@PreDestroy 》 DisposableBean#destory 》 XML (destory-method)

在第二张图中的前两条,其实是在所有的Bean创建之前来完成的,它完成了对bean定义的改造。这些改造中,包括对Bean定义时使用到的一些占位符${}的替换

原文地址:https://www.cnblogs.com/f1194361820/p/6517920.html