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
相关推荐
卓伊凡几秒前
【03】建立隐私关于等相关页面和内容-vue+vite开发实战-做一个非常漂亮的APP下载落地页-支持PC和H5自适应提供安卓苹果鸿蒙下载和网页端访问-优雅草卓
前端
笨笨鸟慢慢飞3 分钟前
Vue3后退不刷新,前进刷新
前端
流星白龙5 分钟前
【Qt】3.认识 Qt Creator 界面
java·开发语言·qt
LuckySusu5 分钟前
【vue篇】SSR 深度解析:服务端渲染的“利”与“弊”
前端·vue.js
LuckySusu5 分钟前
【vue篇】SPA 单页面应用:现代 Web 的革命与挑战
前端·vue.js
LuckySusu6 分钟前
【vue篇】Vue 初始化页面闪动(FOUC)问题终极解决方案
前端·vue.js
fruge8 分钟前
从 0 到 1 理解前端工程化:图表化解析核心逻辑
前端
LuckySusu9 分钟前
【vue篇】技术分析:Template 与 JSX 的本质区别与选型指南
前端·vue.js
机灵猫13 分钟前
深入理解 Java 类加载与垃圾回收机制:从原理到实践
java·开发语言
BestStarLi14 分钟前
个人写码感悟:TailwindCSS不要忽视子选择器
前端