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搭建流程 优点 ...
随机推荐
- Spring-boot 1.5.2 下隐藏Banner
在配置文件中增加: spring.main.banner-mode=off
- JAVA的堆于栈
1. 栈(stack)与堆(heap):都是Java用来在Ram中存放数据的地方.与C++不同,Java自动管理栈和堆,程序员不能直接地设置栈或堆. 2. 栈的优势:存取速度比堆要快,仅次于直接位于C ...
- QT Creator 环境使用 remote debug 调试 arm 程序
这里使用的 4.8.5 QTE 环境,之前尝试过远程使用 GDB 来调试板子上的 QT 程序,但是没成功.没有调试手段比较痛苦,今天又花了点时间,居然搞定了.粗做记录. 工具版本: 1. QtCrea ...
- “Info.plist” couldn’t be removed
Showing All Messages error: failed to remove /Users/Rubert/Library/Developer/Xcode/DerivedData/Proje ...
- cocos2d-js Shader系列3:多重纹理 multiple textures multiple samplers
上一篇,我们学习了怎么便捷的控制sprite的颜色,而这个都是默认一个texture的,如果要实现类似mask的效果,或者更个性化的多纹理效果,怎么实现呢? 这就是这一节需要介绍的内容. 例如上图的效 ...
- java LimitedThreadPool
此线程池一直增长,直到上限,增长后不收缩(因为池子里面的线程是永生的).这个keepAliveTime参数设置的为Long.MAX_VALUE,所以池子里面的线程几乎不会因为idle而被termina ...
- 【PMP】财务测量指标ROI、PBP、NPV、IRR、BCR
各指标说明: 1.投资回报率(ROI) 定义:是指通过投资而应返回的价值,即企业从一项投资活动中得到的经济回报. 1.1 年平均利润相等的情况下 公式:ROI=年平均利润/投资额 案例: 1.2 年平 ...
- Lotus Domino开发心得(一)
—- Lotus Domino 是当今办公自动化系统的主流开发平台之一,目前大部分企业和机构都在使用Lotus Domino 开发自己的无纸办公系统.在开发过程中,我积累了一些小技巧,现在公布出来,希 ...
- 转:3d max 2013 安装教程,凭着一种互联网精神提供给广大朋友
看到有人在ps区咨询如何安装3d max教程,当你进行第一步之前,请先断开网络连接第一步:运行安装程序 第二步:接受安装协议,点击下一步会提示输入序列号 第三步:你会看到已经安装完成了的界面 第四部: ...
- Android API之Telephony.Sms
Telephony.Sms Contains all text based SMS messages. 包含基于SMS消息的所有文本. 1.sms表结构. _ID _id INTEGER(long) ...