(不推荐)
<bean xxxxx init-method="" destroy-method=""/>
注:想看到bean销毁 需要 applicationContext.destroy();
applicationContext不管scope为prototype类型的bean的销毁,你将看不到destroy方法。
spring也支持JSR-250,java的注解@PostConstruct和@PreDestroy(推荐)
本文探讨了Spring框架中Bean的生命周期管理方式,对比了XML配置文件中的init-method和destroy-method属性与JSR-250规范中的@PostConstruct及@PreDestroy注解的应用,并指出后者为推荐实践。
(不推荐)
<bean xxxxx init-method="" destroy-method=""/>
注:想看到bean销毁 需要 applicationContext.destroy();
applicationContext不管scope为prototype类型的bean的销毁,你将看不到destroy方法。
spring也支持JSR-250,java的注解@PostConstruct和@PreDestroy(推荐)
1365

被折叠的 条评论
为什么被折叠?