Spring Bean lifecycle callbacks

See Official document: https://docs.spring.io/spring/docs/current/spring-framework-reference/core.html#beans-factory-lifecycle

 

The first way: using @PostConstruct annotation, the current method of non-labeled init () name, for bean lifecycle initialization operation; @PostConstructand@PreDestroy是当前Bean声明周期的初始化回调和销毁时回调

The second way: The current class implements and  callback interfaceInitializingBeanDisposableBean

The third way: using XML configuration callback method

 

Guess you like

Origin www.cnblogs.com/XingXiaoMeng/p/11455782.html
Recommended