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
相关推荐
赴前尘6 分钟前
golang获取一个系统中没有被占用的端口
开发语言·后端·golang
研☆香6 分钟前
html页面如何精准布局
前端·html
嘴贱欠吻!7 分钟前
JavaSE基础知识
java·开发语言
零下32摄氏度12 分钟前
【前端干货】接口在 Postman 测试很快,页面加载咋就慢?
前端·程序人生·postman
逝水如流年轻往返染尘14 分钟前
Java输入输出
java·开发语言
hqwest15 分钟前
码上通QT实战03--登录逻辑
开发语言·qt·登录·嵌入式实时数据库·界面设计
Alsn8615 分钟前
29.Java中常见加解密算法的基本实现
java·开发语言·算法
沉默王二16 分钟前
TRAE+Gemini,成为我解读 Agent 微服项目的最佳工具
java·后端·程序员
全栈陈序员16 分钟前
说说你对 Vue 的理解
前端·javascript·vue.js·学习·前端框架
多则惑少则明17 分钟前
SpringBoot3整合knife4j(swagger3)
java·spring boot·swagger