一、自定义监听器:

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内部使用各种事件来处理各种任务

 
 

Spring Boot(二)Application events and listeners的更多相关文章

  1. Spring Boot(二十):使用spring-boot-admin对spring-boot服务进行监控

    Spring Boot(二十):使用spring-boot-admin对spring-boot服务进行监控 Spring Boot Actuator提供了对单个Spring Boot的监控,信息包含: ...

  2. Spring Boot 二十个注解

    Spring Boot 二十个注解 占据无力拥有的东西是一种悲哀. Cold on the outside passionate on the insede. 背景:Spring Boot 注解的强大 ...

  3. spring boot(二):启动原理解析

    我们开发任何一个Spring Boot项目,都会用到如下的启动类 @SpringBootApplication public class Application { public static voi ...

  4. Spring Boot(二):数据库操作

    本文主要讲解如何通过spring boot来访问数据库,本文会演示三种方式来访问数据库,第一种是JdbcTemplate,第二种是JPA,第三种是Mybatis.之前已经提到过,本系列会以一个博客系统 ...

  5. spring boot(二十)使用spring-boot-admin对服务进行监控

    上一篇文章<springboot(十九):使用Spring Boot Actuator监控应用>介绍了Spring Boot Actuator的使用,Spring Boot Actuato ...

  6. Spring Boot Common application properties(转载)

    转自官方文档:http://docs.spring.io/spring-boot/docs/current/reference/html/common-application-properties.h ...

  7. Spring Boot学习——Spring Boot配置文件application

    Spring Boot配置文件有两种格式: application.properties 和 application.yml.两种配置文件只需要使用一个. 这两种配置文件的语法有些区别,如下 1. a ...

  8. 【spring boot】application.properties官方完整文档【参考使用】

    官方地址: https://docs.spring.io/spring-boot/docs/current-SNAPSHOT/reference/htmlsingle/ 进入搜索: Appendice ...

  9. 【spring boot】application.properties官方完整文档

    官方地址: https://docs.spring.io/spring-boot/docs/current-SNAPSHOT/reference/htmlsingle/ 进入搜索: Appendice ...

随机推荐

  1. [BZOJ5250][九省联考2018]秘密袭击(DP)

    5250: [2018多省省队联测]秘密袭击 Time Limit: 1 Sec  Memory Limit: 128 MBSubmit: 3  Solved: 0[Submit][Status][D ...

  2. 【拓扑排序】CDOJ1635 琵琶弦上说相思,当时明月在,曾照彩云归

    对于两个相邻的字符串 Si和Si+1 ,如果它们的前k-1位都相同,第k位不相同,那么,在字典序中 Si,k一定在 Si+1,k前面 建立有向边从 Si,k到 Si+1,k,进行拓扑排序 为了保证字典 ...

  3. 【数论】【中国剩余定理】poj1006 生理周期

    CRT用于求解一元线性同余方程组(模数互质),实际上模数不互质我们也可以解决,在之前的某篇文章里提过.如下 http://www.cnblogs.com/autsky-jadek/p/6596010. ...

  4. [AGC019E]Shuffle and Swap

    [AGC019E]Shuffle and Swap 题目大意: 给出两个长度为\(n(n\le10000)\)的\(01\)串\(A_{1\sim n}\)和\(B_{1\sim n}\).两个串均有 ...

  5. bootstrap学习(全局CSS样式)(二)

    标题类:.h1到.h6 页面主体 bootstrap将全局font-size设置为14px,line-height设置为1.428,这些属性 直接赋予元素和所有段落元素. 文本对齐类 text-lef ...

  6. php应用数据库连接中的单例模式

    所谓的单例模式简而言之就是某个类在运行过程中只有一个实例,并且能够自行实例化并为整个系统的运行提供这个实例.在数据库连接中使用单例模式实例化数据库连接对象主要是可以避免重复的实例化对象而造成资源的浪费 ...

  7. Linux(CentOS)下squid代理服务器配置-五岳之巅

    squid是linux下的一款代理服务器软件,他可以共享网络 ,加快访问速度,节约通信带宽,同时防止内部主机受到攻击,限制用户访问,完善网络管理 rpm -qa|grep squidyum insta ...

  8. Android客户端面试题集锦

    声明:本文问题来自但不限于Xoper.ducky大牛的面试总结,网址:http://www.nowcoder.com/discuss/3043,欢迎各位进行补充 JAVA SE 1. 九种基本数据类型 ...

  9. 【js】js数组置空的三种方式

    方式1: var arr = new Array(1,2,3); alert(arr); arr.splice(0, arr.length); alert(arr); 方式2: var arr = n ...

  10. 如何在windows下的Python开发工具IDLE里安装其他模块

    以安装Httplib2模块为例 1 下载模块 到 “https://code.google.com/p/httplib2/” 下载一款适合你的压缩包“httplib2-0.4.0.zip” 2 解压下 ...