(1)、需要配置在META-INF/Spring.factories

  1.ApplicationContextInitializer

  1. //
  2. // Source code recreated from a .class file by IntelliJ IDEA
  3. // (powered by Fernflower decompiler)
  4. //
  5.  
  6. package org.springframework.context;
  7.  
  8. public interface ApplicationContextInitializer<C extends ConfigurableApplicationContext> {
  9. //监听ioc容器启动
  10. void initialize(C var1);
  11. }

  2.SpringApplicationRunListener

  1. //
  2. // Source code recreated from a .class file by IntelliJ IDEA
  3. // (powered by Fernflower decompiler)
  4. //
  5.  
  6. package org.springframework.boot;
  7.  
  8. import org.springframework.context.ConfigurableApplicationContext;
  9. import org.springframework.core.env.ConfigurableEnvironment;
  10.  
  11. public interface SpringApplicationRunListener {
  12. //监听容器开始
  13. void starting();
  14. //SpringBoot环境准备好
  15. void environmentPrepared(ConfigurableEnvironment environment);
  16. //ioc容器准备好了
  17. void contextPrepared(ConfigurableApplicationContext context);
  18. //容器环境加载完成
  19. void contextLoaded(ConfigurableApplicationContext context);
  20.  
  21. void started(ConfigurableApplicationContext context);
  22.  
  23. void running(ConfigurableApplicationContext context);
  24. //SpringBoot创建完成
  25. void failed(ConfigurableApplicationContext context, Throwable exception);
  26. }

(2)、只需要放到ioc容器中即可

  1.ApplicationRunner

  1. //
  2. // Source code recreated from a .class file by IntelliJ IDEA
  3. // (powered by Fernflower decompiler)
  4. //
  5.  
  6. package org.springframework.boot;
  7.  
  8. @FunctionalInterface
  9. public interface ApplicationRunner {
  10. void run(ApplicationArguments args) throws Exception;
  11. }

  2.CommandLineRunner

  1. //
  2. // Source code recreated from a .class file by IntelliJ IDEA
  3. // (powered by Fernflower decompiler)
  4. //
  5.  
  6. package org.springframework.boot;
  7.  
  8. @FunctionalInterface
  9. public interface CommandLineRunner {
  10. void run(String... args) throws Exception;
  11. }

SpringBoot几个重要的事件回调、监听机制的更多相关文章

  1. 深入理解Spring的容器内事件发布监听机制

    目录 1. 什么是事件监听机制 2. JDK中对事件监听机制的支持 2.1 基于JDK实现对任务执行结果的监听 3.Spring容器对事件监听机制的支持 3.1 基于Spring实现对任务执行结果的监 ...

  2. 【spring源码学习】spring的事件发布监听机制源码解析

    [一]相关源代码类 (1)spring的事件发布监听机制的核心管理类:org.springframework.context.event.SimpleApplicationEventMulticast ...

  3. Spring笔记(7) - Spring的事件和监听机制

    一.背景 事件机制作为一种编程机制,在很多开发语言中都提供了支持,同时许多开源框架的设计中都使用了事件机制,比如SpringFramework. 在 Java 语言中,Java 的事件机制参与者有3种 ...

  4. 【cocos2d-js官方文档】事件分发监听机制(摘录)

    简介 游戏开发中一个很重要的功能就是交互,如果没有与用户的交互,那么游戏将变成动画,而处理用户交互就需要使用事件监听器了. 总概: 事件监听器(cc.EventListener) 封装用户的事件处理逻 ...

  5. SpringBoot事件监听机制源码分析(上) SpringBoot源码(九)

    SpringBoot中文注释项目Github地址: https://github.com/yuanmabiji/spring-boot-2.1.0.RELEASE 本篇接 SpringApplicat ...

  6. SpringBoot事件监听机制及观察者模式/发布订阅模式

    目录 本篇要点 什么是观察者模式? 发布订阅模式是什么? Spring事件监听机制概述 SpringBoot事件监听 定义注册事件 注解方式 @EventListener定义监听器 实现Applica ...

  7. Android 开发中的View事件监听机制

    在开发过程中,我们常常根据实际的需要绘制自己的应用组件,那么定制自己的监听事件,及相应的处理方法是必要的.我们都知道Android中,事件的监听是基于回调机制的,比如常用的OnClick事件,你了解它 ...

  8. JAVA事件监听机制学习

    //事件监听机制 import java.awt.*; import java.awt.event.*; public class TestEvent { public static void mai ...

  9. Java swing(awt):事件监听机制的实现原理+简单示例

    (1)实现原理 事件监听机制的实现: 参考图:事件模型_ActionEvent 为了节省资源,系统无法对某个事件进行实时的监听.故实现的机制是当发生某个事件后,处理代码将被自动运行,类似钩子一般.(回 ...

  10. 简单剖析Node中的事件监听机制(一)

    使用js的class类简单的实现一个事件监听机制,不同于浏览器中的时间绑定与监听,类似于node中的时间监听,并且会在接下来的文章中去根据自己的理解去写一下Event模块中的原理. Node.js使用 ...

随机推荐

  1. CUBA如何新增ServiceBean

    简单的方法 在页面MIDDLEWARE模块,可以直接新建.编辑.删除 复杂的方法 在代码中手动实现,则需要1.添加Serviceweb-spring.xml中,添加 <entry key=&qu ...

  2. Java中字符串string的数据类型

    Java中字符串string的数据类型 时间:2017-07-03 08:01:47 YuanMxy 原文:https://blog.csdn.net/YuanMxy/article/details/ ...

  3. Linux 配置Samba服务

    查看系统下是否已经安装了sambarpm -qa |grep samba 安装sambayum -y install samba 配置samba创建目录sambamkdir -p /home/samb ...

  4. 数据挖掘(二)用python实现数据探索:汇总统计和可视化

    今天我们来讲一讲有关数据探索的问题.其实这个概念还蛮容易理解的,就是我们刚拿到数据之后对数据进行的一个探索的过程,旨在了解数据的属性与分布,发现数据一些明显的规律,这样的话一方面有助于我们进行数据预处 ...

  5. outline与border的区别

    在浏览器里,当鼠标点击或使用Tab键让一个链接或者一个radio获得焦点的时候,该元素将会被一个轮廓虚线框围绕.这个轮廓虚线框就是 outline . outline 能告诉用户那一个可以激发事件的h ...

  6. SpaceVim的基本安装和常见问题

    SpaceVim官网:https://spacevim.org/ SpaceVim中文官网:http://spacevim.org/cn/ SpaceVim的Github页面:https://gith ...

  7. 洛谷P2446 大陆争霸

    这是一道dijkstra拓展......不知道为什么被评成了紫题. 有一个很朴素的想法就是每次松弛的时候判断一下那个点是否被保护.如果被保护就不入队. 然后发现写起来要改的地方巨多无比...... 改 ...

  8. typescript类(学习笔记非干货)

    我们声明一个 Greeter类.这个类有3个成员:一个叫做greeting的属性,一个构造函数和一个greet方法. We declare a Greeter class. This class ha ...

  9. JasperReport 中踩过的坑

      Mac Book Pro 10.13.6Jaspersoft Studio community version 6.6.9JDK 8 安装 Jaspersoft Studio Jasper Rep ...

  10. C# TextBox猜想输入和历史记录输入

    什么是猜想输入 当我们在使用查询应用时,输入某个关键字后文本框下面就会自动弹出跟此关键字相附的词组供我们选择,为我们节省了输入的时间,这就是猜想输入,例如:百度,谷歌,等等,如下图: 如上图所示,使用 ...