Spring Boot(二)Application events and listeners
一、自定义监听器: 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的更多相关文章
- Spring Boot(二十):使用spring-boot-admin对spring-boot服务进行监控
Spring Boot(二十):使用spring-boot-admin对spring-boot服务进行监控 Spring Boot Actuator提供了对单个Spring Boot的监控,信息包含: ...
- Spring Boot 二十个注解
Spring Boot 二十个注解 占据无力拥有的东西是一种悲哀. Cold on the outside passionate on the insede. 背景:Spring Boot 注解的强大 ...
- spring boot(二):启动原理解析
我们开发任何一个Spring Boot项目,都会用到如下的启动类 @SpringBootApplication public class Application { public static voi ...
- Spring Boot(二):数据库操作
本文主要讲解如何通过spring boot来访问数据库,本文会演示三种方式来访问数据库,第一种是JdbcTemplate,第二种是JPA,第三种是Mybatis.之前已经提到过,本系列会以一个博客系统 ...
- spring boot(二十)使用spring-boot-admin对服务进行监控
上一篇文章<springboot(十九):使用Spring Boot Actuator监控应用>介绍了Spring Boot Actuator的使用,Spring Boot Actuato ...
- Spring Boot Common application properties(转载)
转自官方文档:http://docs.spring.io/spring-boot/docs/current/reference/html/common-application-properties.h ...
- Spring Boot学习——Spring Boot配置文件application
Spring Boot配置文件有两种格式: application.properties 和 application.yml.两种配置文件只需要使用一个. 这两种配置文件的语法有些区别,如下 1. a ...
- 【spring boot】application.properties官方完整文档【参考使用】
官方地址: https://docs.spring.io/spring-boot/docs/current-SNAPSHOT/reference/htmlsingle/ 进入搜索: Appendice ...
- 【spring boot】application.properties官方完整文档
官方地址: https://docs.spring.io/spring-boot/docs/current-SNAPSHOT/reference/htmlsingle/ 进入搜索: Appendice ...
随机推荐
- Linux含交互的自动登录脚本
近来经常要通过ssh登录服务器,每次输入命令和密码很麻烦,查资料发现有两种解决,一种是本地创建密钥直接登录,另一种是写个脚本. 这里介绍第二种方法,第一种资料也很多,但是觉得没啥意思. 先上脚本: # ...
- 【20181024T3】小C的宿舍【分治】
题面 [错解] 好像就是\(|i-j|+|a_i - b_i|\)唉 嗯开始都加i-1,跑一遍,1~(i-1)加1,i~n 减1,线段树维护. 过样例了呢 哎大样例怎么多了那么多啊 跑了个暴力,多得更 ...
- 【树形dp】Rebuilding Roads
[POJ1947]Rebuilding Roads Time Limit: 1000MS Memory Limit: 30000K Total Submissions: 11934 Accep ...
- 【数论】【Polya定理】【枚举约数】【欧拉函数】【Java】poj2154 Color
你随便写一下出来,发现polya原理的式子里面好多gcd是相同的,gcd(n,i)=k可以改写成gcd(n/k,i/k)=1,也就是说指数为k的项的个数为phi(n/k),就很好求了,最后除的那个n直 ...
- 【c++随手记】编程基础之输入输出
今天试了下noi oj的1.1节,随便总结一下. [cout左对齐右对齐的方法] #include<iostream> #include<cstdio> #include< ...
- Springcloud中的region和zone的使用
一.背景 用户量比较大或者用户地理位置分布范围很广的项目,一般都会有多个机房.这个时候如果上线springCloud服务的话,我们希望一个机房内的服务优先调用同一个机房内的服务 ,当同一个机房的服务不 ...
- PHP5.3魔术方法 __invoke
这个魔幻方法被调用的时机是: 当一个对象当做函数调用的时候, 如果对象定义了__invoke魔幻方法则这个函数会被调用, class Callme { public function __invoke ...
- MYSQL复习笔记5-select-from-where子句
Date: 20140125Auth: Jin参考:http://dev.mysql.com/doc/refman/5.1/zh/sql-syntax.html#select一.select子句主要定 ...
- Jenkins用HTTP Request Plugin插件进行网站的监控/加探针(运维监控)
使用的插件: [HTTP Request Plugin] 思路: 说明:只能是网站是否正常打开,而不能是这个网站业务是否正常,如果是后者,则需要写特定的接口进行请求处理. 1.通过插件,发送GET请求 ...
- zk常见面试题
一个客户端修改了某个节点的数据,其它客户端能够马上获取到这个最新数据吗 ZooKeeper不能确保任何客户端能够获取(即Read Request)到一样的数据,除非客户端自己要求:方法是客户端在获取数 ...