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); }
  • 相关阅读:
    后缀数组
    后缀树
    字典树
    Revit二次开发: 文件损坏
    遍历取出指定文件夹下所有的文件
    Python类、模块、包的区别
    Opencv-python画图基础知识
    JSON C# Class Generator ---由json字符串生成C#实体类的工具
    Handsontable Dropdown with key-value pair
    怎样监听vue.js中v-for全部渲染完成?
  • 原文地址:https://www.cnblogs.com/leaveast/p/10829916.html
Copyright © 2011-2022 走看看