上一篇文章 Spring Bean 生命周期之我从哪里来 说明了我是谁?
和 我从哪里来?
的两大哲学问题,今天我们要讨论一下终极哲学我要到哪里去?
初始化 Spring Bean 有三种方式:
- @PostConstruct
- InitializingBean.afterPropertiesSet()
- init-method
销毁 Spring Bean 同样有三种方式:
- @PreDestroy
- DisposableBean.destroy()
- destroy-method
正所谓,天对地,雨对风; @PostConstruct 对 @PreDestroy;InitializingBean.afterPropertiesSet() 对 DisposableBean.destroy(); init-method 对 destroy-method;雷隐隐,雾蒙蒙;山花对海树,赤日对苍穹;平仄平仄平平仄,仄平仄平仄仄平,仄仄平……