一、自定义监听器:

1、创建:
META-INF/spring.factories
2、添加:
  org.springframework.context.ApplicationListener=com.example.project.MyListener 二、应用程序事件发送顺序如下
Application events are sent in the following order, as your application runs: 1、An ApplicationStartedEvent is sent at the start of a run, but before any processing except the registration of listeners and initializers.
ApplicationStartedEvent在任何处理之前,程序开始运行时被发送,初始化和自定义注册监听事件除外
2、An ApplicationEnvironmentPreparedEvent is sent when the Environment to be used in the context is known, but before the context is created.
ApplicationEnvironmentPreparedEvent在上下文被创建之前,应用环境被已知的上下文环境中使用时被发送
3、An ApplicationPreparedEvent is sent just before the refresh is started, but after bean definitions have been loaded.
ApplicationPreparedEvent在刷新开始之前,beans加载之后被发送
4、An ApplicationReadyEvent is sent after the refresh and any related callbacks have been processed to indicate the application is ready to service requests.
ApplicationReadyEvent在刷新后被发送,并且任何相关的回调都已经被处理,表明该应用程序已经准备好处理服务请求
5、An ApplicationFailedEvent is sent if there is an exception on startup.
ApplicationFailedEvent如果启动时存在异常时被发送

You often won’t need to use application events, but it can be handy to know that they exist. Internally, Spring Boot uses events to handle a variety of tasks.

我们不需要使用应用程序事件,但是很方便的知道他们存在,在SpringBoot内部使用各种事件来处理各种任务

 
 

最新文章

  1. Time Consume Problem
  2. WAMPSERVER PHP版本5.3的降到 5.2?
  3. spring的事物实现
  4. easyui中jquery重复引用问题(tab内存泄露问题)
  5. delphi 712 Word 2
  6. JavaWeb应用中重定向与跳转的区别
  7. Android消息机制之Handler
  8. Android开发新手教程--Android应用程序结构
  9. linux_增加用户组_删除用户
  10. 美团点评2017校招研发offer面经
  11. Es6 新增解构赋值
  12. 检索 COM 类工厂中 CLSID 为 {00024500-0000-0000-C000-000000000046} 的组件时失 败,原因是出现以下错误: 80080005
  13. SQL Server进阶 SQL优化
  14. android 开发 View _8_ 动态图片自定义View
  15. VB.Net 经典画圆方法
  16. Mybatis Generator 使用com.mysql.cj.jdbc.Driver遇到的问题
  17. word-wrap与break-word属性的区别
  18. Android Activity切换与Activity间数据交互
  19. [Arch] 02. Design principle and Software Pattern
  20. win32允许前置窗口

热门文章

  1. C++中的error C2662,const的this指针问题
  2. CodeForces - 1000D Yet Another Problem On a Subsequence
  3. 【贪心】Gym - 101201I - Postman
  4. [PKUSC2018]最大前缀和
  5. Z-Stack协议栈网络号与信道号的设置
  6. Problem A: 零起点学算法80——逆序输出(数组练习)
  7. 原生js封装的一些jquery方法
  8. threadlocal彻底理解,深刻
  9. Kubernetes应用迁移问题定位
  10. maven本地仓库地址的设置