zoukankan      html  css  js  c++  java
  • SpringBoot启动流程分析

    前景提示

      @ComponentScan  的处理都放在org.springframework.context.annotation.ConfigurationClassParser#doProcessConfigurationClass

    1.创建SpringApplication对象

     1 private void initialize(Object[] sources) {
     2         if (sources != null && sources.length > 0) {
     3             this.sources.addAll(Arrays.asList(sources));
     4         }
           //判断当前是否是web应用
    5 this.webEnvironment = deduceWebEnvironment();
           //从类路径下找到META-INF/spring
    6 setInitializers((Collection) getSpringFactoriesInstances( 7 ApplicationContextInitializer.class)); 8 setListeners((Collection) getSpringFactoriesInstances(ApplicationListener.class)); 9 this.mainApplicationClass = deduceMainApplicationClass(); 10 }

            StopWatch stopWatch = new StopWatch();
            stopWatch.start();
            ConfigurableApplicationContext context = null;
            configureHeadlessProperty();
          //获取liestener 从类路径下META-INF/spring.factoise下获取 SpringApplicationRunListeners listeners
    = getRunListeners(args);
          //回调starting方法 listeners.started();
    try {
            //封装命令行参数 ApplicationArguments applicationArguments
    = new DefaultApplicationArguments( args); context = createAndRefreshContext(listeners, applicationArguments); afterRefresh(context, applicationArguments); listeners.finished(context, null); stopWatch.stop(); if (this.logStartupInfo) { new StartupInfoLogger(this.mainApplicationClass) .logStarted(getApplicationLog(), stopWatch); } return context; } catch (Throwable ex) { handleRunFailure(context, listeners, ex); throw new IllegalStateException(ex); }
  • 相关阅读:
    业务领域建模Domain Modeling
    用例建模Use Case Modeling
    分析一套源代码的代码规范和风格并讨论如何改进优化代码
    结合工程实践选题调研分析同类软件产品
    如何提高程序员的键盘使用效率?
    第一次博客作业
    python_同时迭代多个对象
    python_判断奇偶数
    印象笔记markdown使用笔记
    【转】A*算法解决八数码问题
  • 原文地址:https://www.cnblogs.com/leaveast/p/10829916.html
Copyright © 2011-2022 走看看