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
相关推荐
打瞌睡的朱尤1 分钟前
Vue day9 购物车,项目,vant组件库,vw,路由
前端·javascript·vue.js
jjjxxxhhh1236 分钟前
【加密】-AES与对称加密
java·服务器·网络
临水逸7 分钟前
飞牛fnos 2025 漏洞Java跨域URL浏览器
java·开发语言·安全·web安全
yaoxin5211239 分钟前
324. Java Stream API - 实现 Collector 接口:自定义你的流式收集器
java·windows·python
H Corey10 分钟前
数据结构与算法:高效编程的核心
java·开发语言·数据结构·算法
米羊12120 分钟前
Struts 2 漏洞(上)
java·后端·struts
訫悦33 分钟前
C++自带的set get语法(MSVC)
开发语言·c++
SmartBrain34 分钟前
Python 特性(第一部分):知识点讲解(含示例)
开发语言·人工智能·python·算法
galaxyffang43 分钟前
Java堆内存诊断:从工具使用到实战分析
java·jvm
01二进制代码漫游日记1 小时前
自定义类型:联合和枚举(一)
c语言·开发语言·学习·算法