SpringApplication初始化
| SpringApplication: | |
| private void initialize(Object[] sources) { | |
| if (sources != null && sources.length > 0) { | |
| this.sources.addAll(Arrays.asList(sources)); | |
| } | |
| this.webEnvironment = deduceWebEnvironment(); | |
| // 从spring.factories里读取所有 ApplicationContextInitializer,并记入 SpringApplication | |
| setInitializers((Collection) getSpringFactoriesInstances( | |
| ApplicationContextInitializer.class)); | |
| // 从spring.factories里读取所有 ApplicationListener,并记入 SpringApplication | |
| setListeners((Collection) getSpringFactoriesInstances(ApplicationListener.class)); | |
| this.mainApplicationClass = deduceMainApplicationClass(); | |
| } | |
| public ConfigurableApplicationContext run(String... args) { | |
| StopWatch stopWatch = new StopWatch(); | |
| stopWatch.start(); | |
| ConfigurableApplicationContext context = null; | |
| FailureAnalyzers analyzers = null; | |
| configureHeadlessProperty(); | |
| // 从spring.factories里读取所有 SpringApplicationRunListener,监听springboot启动,参考:org.springframework.boot.context.event.EventPublishingRunListener | |
| SpringApplicationRunListeners listeners = getRunListeners(args); | |
| listeners.starting(); | |
| try { | |
| ApplicationArguments applicationArguments = new DefaultApplicationArguments( | |
| args); | |
| ConfigurableEnvironment environment = prepareEnvironment(listeners, | |
| applicationArguments); | |
| Banner printedBanner = printBanner(environment); | |
| // web环境下默认的 ApplicationContext: org.springframework.boot.context.embedded.AnnotationConfigEmbeddedWebApplicationContext | |
| // 非web环境下默认的 ApplicationContext: org.springframework.context.annotation.AnnotationConfigApplicationContext | |
| context = createApplicationContext(); | |
| analyzers = new FailureAnalyzers(context); | |
| // org.springframework.cloud.bootstrap.config.PropertySourceBootstrapProperties 会通过 ApplicationContextInitializer,准备 PropertySource | |
| // PropertySourceBootstrapProperties 收集 PropertySourceLocator 来获得PropertySource | |
| // 其中 org.springframework.cloud.config.client.ConfigServicePropertySourceLocator 是 Cloud Config Client 提供的 PropertySourceLocator | |
| prepareContext(context, environment, listeners, applicationArguments, | |
| printedBanner); | |
| // 调用 context.refresh | |
| refreshContext(context); | |
| 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, analyzers, ex); | |
| throw new IllegalStateException(ex); | |
| } | |
| } |
SpringApplication初始化的更多相关文章
- SpringBoot启动流程分析(一):SpringApplication类初始化过程
SpringBoot系列文章简介 SpringBoot源码阅读辅助篇: Spring IoC容器与应用上下文的设计与实现 SpringBoot启动流程源码分析: SpringBoot启动流程分析(一) ...
- springboot源码解析 - 构建SpringApplication
1 package com.microservice.framework; 2 3 import org.springframework.boot.SpringApplication; 4 impor ...
- Spring Boot 2.0系列文章(七):SpringApplication 深入探索
关注我 转载请务必注明原创地址为:http://www.54tianzhisheng.cn/2018/04/30/springboot_SpringApplication/ 前言 在 Spring B ...
- Spring Boot 启动(一) SpringApplication 分析
Spring Boot 启动(一) SpringApplication 分析 Spring 系列目录(https://www.cnblogs.com/binarylei/p/10198698.html ...
- 【附3】springboot源码解析 - 构建SpringApplication
package com.microservice.framework; import org.springframework.boot.SpringApplication; import org.sp ...
- 附3 springboot源码解析 - 构建SpringApplication
package com.microservice.framework; import org.springframework.boot.SpringApplication; import org.sp ...
- SpringBoot SpringApplication底层源码分析与自动装配
目录 抛出问题 @SpringBootApplication注解剖析 SpringApplication类剖析 第一步:配置SpringBoot Bean来源 第二步 :自动推断SpringBoot的 ...
- SpringBoot源码分析之---SpringBoot项目启动类SpringApplication浅析
源码版本说明 本文源码采用版本为SpringBoot 2.1.0BUILD,对应的SpringFramework 5.1.0.RC1 注意:本文只是从整体上梳理流程,不做具体深入分析 SpringBo ...
- SpringBoot源码修炼—系统初始化器
SpringBoot源码修炼-系统初始化器 传统SSM框架与SpringBoot框架简要对比 SSM搭建流程 缺点: 耗时长 配置文件繁琐 需要找合适版本的jar包 SpringBoot搭建流程 优点 ...
随机推荐
- VCAP5-DCA Objective 1.3 – Configure and Manage Complex Multipathing and PSA Plug-ins
http://virtuallyhyper.com/2012/10/vcap5-dca-objective-1-3-configure-and-manage-complex-multipathing- ...
- MySQL auto_increment初始值设置
http://blog.csdn.net/u011439289/article/details/48055917 DROP TABLE IF EXISTS zan1; CREATE TABLE zan ...
- 算法笔记_219:泊松分酒(Java)
目录 1 问题描述 2 解决方案 1 问题描述 泊松是法国数学家.物理学家和力学家.他一生致力科学事业,成果颇多.有许多著名的公式定理以他的名字命名,比如概率论中著名的泊松分布. 有一次闲暇时,他 ...
- 顺利编译 binutiles-gcc-glibc
恩,前面一篇弃了,先知道怎么能成功,还有要避开哪些坑,然后再去仔细研究到底咋回事. 这里顺利编译 arm-lfs-linux-gnueabi , 参考了下面的资料: 1. <Linux From ...
- std::accumulate使用的一个小细节
今天使用std::accumulate模板函数的时候出现了一个错误,特此记录一下. #include <iostream> #include <numeric> int mai ...
- Ubuntu16.04 安装Processing
下载 在 https://processing.org/ 上下载最新的linux 64bit版本gzip文件, 当前是 http://download.processing.org/processin ...
- 使用Docker运行Java Web应用
前言 Tomcat是目前比较流行的Web应用服务器,深受Java爱好者的喜爱.通常J2EE应用的产出物是一个war包,这篇文章将为你介绍如何使用Docker运行Tomcat+war包的Java Web ...
- (原)python中不同文件之间使用所谓的全局变量
转载请注明出处: http://www.cnblogs.com/darkknightzh/p/8108640.html 参考网址: https://www.cnblogs.com/20150705-y ...
- (原)ubuntu中安装kate
转载请注明出处: http://www.cnblogs.com/darkknightzh/p/6339642.html 参考网址: https://kate-editor.org/build-it/# ...
- Linux删除文件出现rm: cannot remove `.user.ini': Operation not permitted
转自:https://blog.csdn.net/sinat_35861727/article/details/79040755 在Linux中rm -rf的威力是十分巨大的,特别是附带了 -f 参数 ...