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; @PostConstruct
and@PreDestroy是当前Bean声明周期的初始化回调和销毁时回调
The second way: The current class implements and callback interfaceInitializingBean
DisposableBean
The third way: using XML configuration callback method