createApplicationContext 加载各种PostProcessor

java 复制代码
public ConfigurableApplicationContext run(String... args) {
   StopWatch stopWatch = new StopWatch();
   stopWatch.start();
   ConfigurableApplicationContext context = null;
   Collection<SpringBootExceptionReporter> exceptionReporters = new ArrayList<>();
   configureHeadlessProperty();
   SpringApplicationRunListeners listeners = getRunListeners(args);
   listeners.starting();
   try {
      ApplicationArguments applicationArguments = new DefaultApplicationArguments(args);
      ConfigurableEnvironment environment = prepareEnvironment(listeners, applicationArguments);
      configureIgnoreBeanInfo(environment);
      Banner printedBanner = printBanner(environment);
      context = createApplicationContext();
      exceptionReporters = getSpringFactoriesInstances(SpringBootExceptionReporter.class,
            new Class[] { ConfigurableApplicationContext.class }, context);
      prepareContext(context, environment, listeners, applicationArguments, printedBanner);
      refreshContext(context);
      afterRefresh(context, applicationArguments);
      stopWatch.stop();
      if (this.logStartupInfo) {
         new StartupInfoLogger(this.mainApplicationClass).logStarted(getApplicationLog(), stopWatch);
      }
      listeners.started(context);
      callRunners(context, applicationArguments);
   }
   catch (Throwable ex) {
      handleRunFailure(context, ex, exceptionReporters, listeners);
      throw new IllegalStateException(ex);
   }

   try {
      listeners.running(context);
   }
   catch (Throwable ex) {
      handleRunFailure(context, ex, exceptionReporters, null);
      throw new IllegalStateException(ex);
   }
   return context;
}
  1. createApplicationContext 加载各种PostProcessor
  2. prepareContext 加载ServerMain类
  3. refreshContext 调用 1步加载的PostProcessor然后实例化
  4. PostProcessor实例化后就去加载其他的类,生成Beandefinition
java 复制代码
ConfigurationClassPostProcessor

PostProcessorRegistrationDelegate#invokeBeanFactoryPostProcessors

ClassPathScanningCandidateComponentProvider
相关推荐
计算机毕设VX:Fegn08956 分钟前
计算机毕业设计|基于springboot + vue个人博客系统(源码+数据库+文档)
java·数据库·vue.js·spring boot·后端·课程设计
鱼鱼块14 分钟前
彻底搞懂 React useRef:从自动聚焦到非受控表单的完整指南
前端·react.js·面试
2501_9466756416 分钟前
Flutter与OpenHarmony打卡轮播图组件
java·javascript·flutter
ray96322 分钟前
Python——函数参数传递方式
开发语言·python
独自破碎E24 分钟前
Spring Boot 3.x和2.x版本相比有哪些区别与改进?
java·spring boot·后端
BullSmall24 分钟前
Socket中断原因与处理全攻略
开发语言
十五年专注C++开发24 分钟前
浅谈Qt中的QSql模块整体设计
开发语言·数据库·c++·qt
梅羽落28 分钟前
python武器化开发_01
开发语言·python·php
Joe_Blue_0232 分钟前
Matlab 入门案例介绍——如何创建脚本
开发语言·matlab·matlab 入门案例
nwsuaf_huasir33 分钟前
积分旁瓣电平-matlab函数
前端·javascript·matlab