7_1.springboot2.x启动配置原理_1.创建SpringApplication对象
环境准备
springboot2.1.9、idea2019、
pom.xml

解析
几个重要的事件回调机制
配置在META-INF/spring.factories
ApplicationContextInitializer
SpringApplicationRunListener
只需要放在ioc容器中
ApplicationRunner
CommandLineRunner
在主配置类打断点进行调试

可见springboot应用程序分为两步:1、创建SpringApplication对象;2、运行run方法
创建SpringApplication对象
public SpringApplication(ResourceLoader resourceLoader, Class<?>... primarySources) {
this.resourceLoader = resourceLoader;
//判断主配置类不能为空
Assert.notNull(primarySources, "PrimarySources must not be null");
//保存主配置类
this.primarySources = new LinkedHashSet<>(Arrays.asList(primarySources));
//判断当前是否一个web应用
this.webApplicationType = WebApplicationType.deduceFromClasspath();
//从类路径下找到META‐INF/spring.factories配置的所有ApplicationContextInitializer;然后保存
setInitializers((Collection) getSpringFactoriesInstances(ApplicationContextInitializer.class));
//从类路径下找到ETA‐INF/spring.factories配置的所有ApplicationListener
setListeners((Collection) getSpringFactoriesInstances(ApplicationListener.class));
//从多个配置类中找到有main方法的主配置类
this.mainApplicationClass = deduceMainApplicationClass();
}
setInitializers((Collection) getSpringFactoriesInstances(ApplicationContextInitializer.class));

setListeners((Collection) getSpringFactoriesInstances(ApplicationListener.class));

查看已创建的SpringApplication对象:

之后运行run方法。。
7_1.springboot2.x启动配置原理_1.创建SpringApplication对象的更多相关文章
- 7_2.springboot2.x启动配置原理_2.运行run方法
当创建完SpringApplication对象之后运行run方法 public ConfigurableApplicationContext run(String... args) { StopWat ...
- 7_3.springboot2.x启动配置原理_3.事件监听机制
事件监听机制配置在META-INF/spring.factories ApplicationContextInitializer SpringApplicationRunListenerioc容器中的 ...
- springboot启动配置原理之一(创建SpringApplication对象)
几个重要的事件回调机制 配置在META-INF/spring.factories ApplicationContextInitializer SpringApplicationRunListener ...
- 【SpringBoot1.x】SpringBoot1.x 启动配置原理 和 自定义starter
SpringBoot1.x 启动配置原理 和 自定义starter 启动配置原理 本节源码 启动过程主要为: new SpringApplication(sources) 创建 SpringAppli ...
- 七、Spring Boot 启动配置原理
几个重要的事件回调机制 配置在META-INF/spring.factories ApplicationContextInitializer SpringApplicationRunListener ...
- Spring boot 启动配置原理
配置在META-INF/spring.factories 有几个主要的类 ApplicationContextInitializer 创建SpringAplication SpringAppli ...
- SpringBoot的启动配置原理
一.启动流程 创建SpringApplication对象 public class SpringApplication { public SpringApplication(Class... prim ...
- springboot 启动配置原理【转】【补】
创建应用 几个重要的事件回调机制 , 配置在META-INF/spring.factories ApplicationContextInitializer SpringApplicationRunL ...
- SpringBoot 启动配置原理
几个重要的事件回调机制 ApplicationContextInitializer SpringApplicationRunListener ApplicationRunner CommandLine ...
随机推荐
- Spring - @ManagedResource, @ManagedOperation, @ManagedAttribute
总结 通过annotation (@ManagedResource, @ManagedOperation, @ManagedAttribute)注解注册MBean到JMX实现监控java运行状态 参考 ...
- thinkphp 错误调试
如果需要我们可以使用E方法输出错误信息并中断执行,例如: //输出错误信息,并中止执行 E($msg); 原3.1版本中的halt方法已经废弃,请使用E函数代替.
- 在vue中使用handsontable
1.使用npm安装 npm install handsontable @handsontable/vue 2.定义结构 <hot-table :settings="hotSetting ...
- (转) mysql的分区技术 .
转:http://blog.csdn.net/feihong247/article/details/8100960 一.概述 当 MySQL的总记录数超过了100万后,会出现性能的大幅度下降吗?答案是 ...
- 在桌面上显示IE图标(非快捷键)
1.在桌面点击右键选择"属性"打开"显示属性",选择"桌面">"自定义桌面">"常规"& ...
- 直接用编译器按ctrl+F5运行和双击运行结果不一样
是因为进程权限的问题,需要添加下面的代码: BOOL EnableDebugPrivilege() { HANDLE hToken; BOOL fOk=FALSE; if(OpenProcessTok ...
- 【转】Linux(CentOS) vps安装xfce桌面+VNC
以前我发过一篇文章利用vnc远程连接VPS桌面,其中用到的是kde桌面,后来知道xfce总体来说比kde占得内存还小些,因为xfce轻便.简单,今天因为一些原因需要在我的vps上搭建用户桌面,所以就试 ...
- POJ-1836-Alignment-双向LIS(最长上升子序列)(LIS+LSD)+dp
In the army, a platoon is composed by n soldiers. During the morning inspection, the soldiers are al ...
- Git及github使用(一)客户端与本地关联
一.下载安装git客户端 1.官网下载地址:https://git-scm.com/ 2.选择自己相应的系统进行下载即可(windows一路默认安装) 二.配置git 1.在github上注册自己的账 ...
- centos 7 ifcnfig提示:bash: ifconfig: command not found的解决方法
接着上一篇,配置完IP地址之后因为ip addr命令不符合我们的习惯,需要添加ifconfig命令 输入命令 yum -y install net-tools 即可解决
