zoukankan      html  css  js  c++  java
  • 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内部使用各种事件来处理各种任务

     
     
  • 相关阅读:
    Nginx系列p5:进程管理(信号)
    Nginx系列p4:进程结构
    one_day_one_linuxCmd---crontab 命令
    Nginx系列p3:实现一个具有缓存功能的反向代理服务器
    Nginx系列p2:重载,热部署,日志分割
    Nginx系列p1:安装
    数据链路层
    物理层习题与真题
    物理层
    计算机网络体系结构习题与真题
  • 原文地址:https://www.cnblogs.com/sallet/p/5824679.html
Copyright © 2011-2022 走看看