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
相关推荐
专注VB编程开发20年41 分钟前
python语法设计、IDE 生态、平台策略、解析器逻辑这四层的矛盾点
开发语言·ide·python
Roselind_Yi42 分钟前
池化对比:CNN池化 VS Java线程池
java·人工智能·经验分享·笔记·深度学习·神经网络·cnn
极客密码8 小时前
感谢雷总!Mimo大模型价值¥659/月的 MAX 套餐,让我免费领到了!
前端·ai编程·claude
潜创微科技8 小时前
IT6520:USB‑C 转 MIPI 芯片方案 4K@120Hz 高清显示
c语言·开发语言
深念Y9 小时前
我明白为什么B站没法在浏览器开直播了——Windows Chrome推流踩坑全记录
前端·chrome·webrtc·浏览器·srs·直播·flv
言之。9 小时前
【Python】免费的中文 AI 配音方案
开发语言·人工智能·python
zhangxingchao9 小时前
AI应用开发七:可以替代 RAG 的技术
前端·人工智能·后端
天天进步20159 小时前
Python全栈项目:从零手操一个高性能 API 网关
开发语言·python
Sun@happy9 小时前
现代 Web 前端渗透——基础篇(1)
前端·web安全
Java面试题总结9 小时前
java高频面试题(2026最新)
java·开发语言·jvm·数据库·spring·缓存