运行阶段
- 加载:SpringApplication 运行监听器
- 运行:SpringApplication 运行监听器
- SpringApplicationRunListener
- SpringApplicationRunListener
- 监听:Spring Boot事件、Spring事件
- ApplicationStartingEvent
- ApplicationEnvironmentPreparedEvent
- ApplicationContextInitializedEvent
- ApplicationPreparedEvent
- ApplicationStartedEvent
- ApplicationReadyEven
- ApplicationFailedEvent
- 创建:
- 应用上下文
- 根据准备阶段的推断Web应用类型创建对应的ConfigurableApplicationContext实例:
- Web Reactive: AnnotationConfigReactiveWebServerApplicationContext
- Web Servlet:AnnotationConfigServletWebServerApplicationContext
- 非Web:AnnotationConfigApplicationContext
- 、Environment[抽象环境]
- Web Reactive:StandardEnvironment
- Web Servlet:StandardServletEnvironment
- 非Web:StandardEnvironment
- 应用上下文
/**
* Spring 应用上下文 引导类
*/
@SpringBootApplication
public class SpringApplicationContextBootstrap {
public static void main(String[] args) {
ConfigurableApplicationContext context = new SpringApplicationBuilder(SpringApplicationContextBootstrap.class)
// .web(WebApplicationType.NONE) // 调制为AnnotationConfigApplicationContext
.run(args);
// 默认是web Servlet
// ConfigurableApplicationContext 类型: AnnotationConfigServletWebServerApplicationContext
System.out.println("ConfigurableApplicationContext 类型: " + context.getClass().getSimpleName());
System.out.println("Environment 类型: " + context.getEnvironment().getClass().getSimpleName());
context.close();
}
}