标签:loaded 实现 contex rri rabl rgs throw ade lan
利用 Spring 工厂加载机制,读取 SpringApplicationRunListener 对象集合,并且封装到组合类
SpringApplicationRunListeners
SpringApplication application, String[] args
参数的构造函数public class HelloWorldRunListener implements SpringApplicationRunListener {
public HelloWorldRunListener(SpringApplication application, String[] args) {
}
// Spring 应用刚启动
@Override
public void starting() {
System.out.println("HelloWorldRunListener.starting()...");
}
// ConfigurableEnvironment 准备妥当,允许将其调整
@Override
public void environmentPrepared(ConfigurableEnvironment environment) {
}
// configurableApplicationContext 准备妥当,允许将其调整
@Override
public void contextPrepared(ConfigurableApplicationContext context) {
}
// ConfigurableApplicationContext 已装载,但仍未启动
@Override
public void contextLoaded(ConfigurableApplicationContext context) {
}
// ConfigurableApplicationContext 已启动,此时 Spring Bean 已初始化完成
@Override
public void started(ConfigurableApplicationContext context) {
}
// Spring 应用正在运行
@Override
public void running(ConfigurableApplicationContext context) {
}
// Spring 应用运行失败
@Override
public void failed(ConfigurableApplicationContext context, Throwable exception) {
}
}
# SpringApplicationRunListener
org.springframework.boot.SpringApplicationRunListener=com.imooc.diveinspringboot.run.HelloWorldRunListener
SpringBoot加载运行时监听器(SpringApplicationRunListeners)
标签:loaded 实现 contex rri rabl rgs throw ade lan
原文地址:https://www.cnblogs.com/fjf3997/p/13035880.html