spring的bean的生命周期 回调方法

时间:2022-06-23 18:58:57

 (不推荐)

<bean   xxxxx    init-method=""   destroy-method=""/>

注:想看到bean销毁 需要 applicationContext.destroy();

applicationContext不管scope为prototype类型的bean的销毁,你将看不到destroy方法。

 

spring也支持JSR-250,java的注解@PostConstruct和@PreDestroy(推荐)