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 分钟前
【华为仓颉独特优势】第11课:回到主场——HarmonyOS 上的仓颉:ArkTS 互操作与“宿主问题”的终极答卷
开发语言·华为·harmonyos·编程语言理论·仓颉·cangjie·通用编程语言
IT研究室7 分钟前
最新计算机毕业设计选题推荐-基于spring boot的家政保洁预约系统-网站-文档指导-Java-springboot
java·spring boot·课程设计
FYKJ_20107 分钟前
springboot网上汽车租赁系统93523-计算机毕业设计、课程设计
java·vue.js·spring boot·后端·python·汽车·课程设计
master33611 分钟前
Java 是如何调用 C 语言接口的?native 方法的完整工作原理
java·c语言·开发语言
جيون داد ناالام ميづ12 分钟前
【MQ与中间件】容器内Java服务发不出邮件:docker network connect与JVM的DNS负缓存
java·docker·中间件
计算机毕业编程指导师18 分钟前
计算机毕设选题:马术俱乐部管理系统 SpringBoot 全解析(功能模块 + 数据表设计 + 核心代码)
java·spring boot·后端·mysql·elementui·毕业设计·马术俱乐部
lgbisha22 分钟前
银河麒麟:软链接还在却打不开,怎么查它指向了哪里
linux·服务器·前端·银河麒麟
雾时之林24 分钟前
K8S HPA 自动扩缩容与 StatefulSet 有状态应用
java·容器·kubernetes
汤姆宝库34 分钟前
GraphRAG:把语料抽成图谱再回答全局问题的完整做法
开发语言·python·机器学习
Highcharts.js7 小时前
成分占比饼图代码|常用可视化图表开发示例
java·开发语言·仪表盘·highcharts·实战代码·响应式图表