SpringBoot应用启动以及关闭时完成某些操作
一:启动时完成数据加载等需求
实现ApplicationListener接口,官方文档截图:

ApplicationListener接口的泛型类可以使用ApplicationStartedEvent和ApplicationReadyEvent

应用监听器事件执行先后顺序如下:
- ApplicationStartingEvent
- ApplicationEnvironmentPreparedEvent
- ApplicationPreparedEvent
- ApplicationStartedEvent
- ApplicationReadyEvent
- ApplicationFailedEvent
实现CommandLineRunner和ApplicationRunner完成启动加载数据


二. 关闭时完成某些操作
- 实现ApplicationListener
- 实现DisposableBean接口
