spring boot中支持的事件類型定在org.springframework.boot.context.event包中,目前支持的事件類型有如下6種:
執行順序:
1、ApplicationStartingEvent spring boot最開始啟動時觸發。
2、ApplicationEnvironmentPreparedEvent spring boot環境已經准備好,但上下文還沒有創建時觸發。
3、ApplicationPreparedEvent spring boot上下文context創建完成,但此時spring中的bean是沒有完全加載完成的。
4、ApplicationStartedEvent spring boot開始啟動時觸發,可以在SpringApplication啟動之前做一些手腳。
5、ApplicationReadyEvent spring boot上下文已經准備完畢的時候觸發。
err、ApplicationFailedEvent spring boot啟動失敗觸發。
Spring boot學習,推薦:https://gitee.com/didispace/SpringBoot-Learning