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
相关推荐
excel11 小时前
Vue SFC 编译核心解析(第 4 篇)——普通 <script> 与 <script setup> 的合并逻辑
前端
cs麦子11 小时前
C语言--函数(function)
c语言·开发语言
snowfoootball11 小时前
python函数及面向过程高级特性
开发语言·python
牢七11 小时前
javan小案例。
java
excel11 小时前
Vue SFC 编译核心解析(第 1 篇)——compileScript 总体流程概览
前端
excel11 小时前
Vue 编译器中的 processAwait 实现深度解析
前端
excel11 小时前
Vue SFC 编译核心解析(第 2 篇)——宏函数解析机制
前端
是苏浙11 小时前
零基础入门C语言之C语言实现数据结构之顺序表
c语言·开发语言·数据结构
excel11 小时前
🔍 Vue 模板编译中的资源路径转换机制:transformAssetUrl 深度解析
前端
excel11 小时前
Vue 模板编译中的 srcset 机制详解:从 HTML 语义到编译器实现
前端