玩转springboot之SpringApplicationRunListener

SpringApplicationRunListener

在看源码的时候经常看到

SpringApplicationRunListeners listeners = getRunListeners(args);
listeners.starting();

这个SpringApplicationRunListeners是用来干嘛的呢

public interface SpringApplicationRunListener {

   /**
    * run方法首次启动的时候立刻调用,可以进行早期的初始化操作
    */
   void starting();

   /**
    * 环境被准备好的时候被调用,但是在ApplicationContext创建之前
    */
   default void environmentPrepared(ConfigurableEnvironment environment) {
	}

   /**
    * ApplicationContext已经被创建且准备好了,但是源还没被加载
    */
   default void contextPrepared(ConfigurableApplicationContext context) {
	}

   /**
    * ApplicationContext已经被加载但是在刷新之前
    */
   default void contextLoaded(ConfigurableApplicationContext context) {
	}

   /**
	 * @since 2.0.0    ApplicationContext已经被刷新且启动但是CommandLineRunner和ApplicationRunner还没有被调用
	 */
	default void started(ConfigurableApplicationContext context) {
	}

	/**
	 * @since 2.0.0   run方法完成之前被调用,ApplicationContext已经被刷新且启动,CommandLineRunner和ApplicationRunner已经被调用
	 */
	default void running(ConfigurableApplicationContext context) {
	}

	/**
	 * @since 2.0.0  运行ApplicationContext出错
	 */
	default void failed(ConfigurableApplicationContext context, Throwable exception) {
	}

}

[https://zhhll.icu/2022/框架/springboot/基础/20. SpringApplicationRunListener/](https://zhhll.icu/2022/框架/springboot/基础/20. SpringApplicationRunListener/)

相关推荐

  1. springbootSpringApplicationRunListener

    2024-07-14 14:44:03       21 阅读
  2. springbootspringboot项目监测

    2024-07-14 14:44:03       24 阅读
  3. springbootSpringBoot单元测试

    2024-07-14 14:44:03       20 阅读
  4. springbootSpringBoot使用jsp

    2024-07-14 14:44:03       17 阅读
  5. springbootspringboot启动原理

    2024-07-14 14:44:03       19 阅读
  6. springbootxxxRunner接口使用

    2024-07-14 14:44:03       22 阅读
  7. springbootspringboot定制化tomcat

    2024-07-14 14:44:03       28 阅读
  8. springbootspringboot使用外置tomcat进行运行

    2024-07-14 14:44:03       20 阅读
  9. 7天 Golang 标准库 sort

    2024-07-14 14:44:03       54 阅读

最近更新

  1. docker php8.1+nginx base 镜像 dockerfile 配置

    2024-07-14 14:44:03       52 阅读
  2. Could not load dynamic library ‘cudart64_100.dll‘

    2024-07-14 14:44:03       54 阅读
  3. 在Django里面运行非项目文件

    2024-07-14 14:44:03       45 阅读
  4. Python语言-面向对象

    2024-07-14 14:44:03       55 阅读

热门阅读

  1. ESP32部署TensorFlow Lite(TODO)

    2024-07-14 14:44:03       17 阅读
  2. 滑动窗口区间最大最小值模板

    2024-07-14 14:44:03       20 阅读
  3. php探针

    2024-07-14 14:44:03       21 阅读
  4. 基于深度学习的问答系统

    2024-07-14 14:44:03       19 阅读
  5. 【C语言】多进程服务器

    2024-07-14 14:44:03       25 阅读
  6. 日常学习--20240713

    2024-07-14 14:44:03       17 阅读
  7. qt 布局有多少种

    2024-07-14 14:44:03       17 阅读
  8. 并发漏洞介绍

    2024-07-14 14:44:03       17 阅读
  9. 展开说说:Android之View基础知识解析

    2024-07-14 14:44:03       14 阅读
  10. 代码随想录算法训练营第35天

    2024-07-14 14:44:03       18 阅读