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
相关推荐
七夜zippoe几秒前
设计模式在Python中的优雅实现:从新手到专家的进阶指南
开发语言·python·设计模式·性能优化·pythonic
有味道的男人2 分钟前
京东关键词搜索商品列表的Python爬虫实战
开发语言·爬虫·python
IT_陈寒3 分钟前
Redis 7.0 性能优化实战:5个让我降低50%内存占用的核心技巧
前端·人工智能·后端
云栖梦泽3 分钟前
鸿蒙企业级应用安全开发实战:从数据加密到合规防护
开发语言·鸿蒙系统
情缘晓梦.5 分钟前
C语言结构体
c语言·开发语言
leiming65 分钟前
c++ 内建函数对象
开发语言·c++·算法
2201_757830876 分钟前
ThreadLocal
java·服务器·前端
2301_807288637 分钟前
MPRPC项目(第十天,日志功能实现)
开发语言·c++
YJlio7 分钟前
PsPing 学习笔记(14.10):常见错误与排错思路——从“不可达”到“端口拒绝”
开发语言·笔记·python·学习·django·pdf·pygame
2501_9418714513 分钟前
面向微服务健康检查与自动恢复机制的互联网系统高可用设计与多语言工程实践分享
运维·服务器·前端