一、自定义监听器:

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. RMQ入门

    注:为方便描述算法 便于记忆 所以ST的代码用Pascal书写 见谅 RMQ,即Range Minimum/Maximum Query问题,给定一个区间,询问不同子区间的最值问题. 当询问次数较少时, ...

  2. 【插头dp】CDOJ1690 这是一道比CCCC简单题难的简单题

    最裸的插头dp,可参见大白书. #include<cstdio> #include<cstring> using namespace std; #define MOD 1000 ...

  3. 【动态规划】mr359-最大公约数之和

    [题目大意] 选取和不超过S的若干个不同的正整数,使得所有数的约数(不含它本身)之和最大. 输入一个正整数S. 输出最大的约数之和. 样例输入 Sample Input 11 样例输出 Sample ...

  4. Team Queue(POJ 2259)

    题意:有若干个团体,每个团体有若干个元素,他们按次序来排队,如果队列中已经有同一团体的元素在,则可以插队到它后面,模拟这个过程 思路:用map存下元素与团体的关系,并开2个队列,一个存整体队伍的排列( ...

  5. Java程序运行时内存划分

    1.Java程序跨平台运行的原因 主要原因是:各种平台的JVM和字节码文件 Java源程序--具体平台的机器代码文件---被编译器翻译成平台无关的Class文件,又用特定JVM运行字节码文件,JVM在 ...

  6. [Asp.net本质论]重新认识url

    引言 之前大部分时间,一直在学c#,打算将asp.net本质论好好学习一下,之前虽然已经看了两边了,总感觉看过,没做笔记等于白看了,一点印象也没.打算将书中的代码,自己实现一下,在敲代码时要一直反思, ...

  7. Tomcat监控—Status页面

    原文:http://jingyan.baidu.com/article/925f8cb8f3d925c0dce05677.html 修改配置文件tomcat-users(该文件在Tomcat安装程序根 ...

  8. 【spring data jpa】根据一个时间字段 查询 时间段的处理方法

    处理方法  包含结束时间00.00.00 Date createDate = boxCodeLog.getCreateDate(); if (createDate != null){ LocalDat ...

  9. 从Cell的视图推出一个新的界面

    先写一个方法, 强制增加一个navigation的属性. 这样self就可以调出来navigation了 - (UINavigationController*)naviController { for ...

  10. Windows Server 2008 远程桌面连接拒绝

    (1)远程连接的时候在本地用户名添加域名 现象:在Windows2008R2配置成域控制器前,还没有安装AD,管理员Admistrator以及新创建的用户(创建的时候将该用户加入远程桌面管理组),发现 ...