杂记-1

http2新特性

1. 二进制帧

http1 header是纯文本传输, http2是二进制

2. 多路复用

http2 把HTTP消息分解成独立的帧, 交错传输, 然后在另一端组装

http1 一个链接 每次只能发送一个请求, 得到响应后再发送另一个请求

3. 头部压缩

springboot2.x与1.x区别

1. JDK最低要求1.8

2. 响应式编程WebFlux

3. http2的支持

4. 第三方类库升级(Spring Framework 5+等)(可以说springboot2.x的新特性来自于spring framework5的新特性)

5. 默认HikariCP连接池

6. 功能完善和加强(配置属性绑定, kotlin,Actuator加强, web加强,Quartz支持)

springboot 启动过程

https://www.processon.com/view/link/59812124e4b0de2518b32b6e

https://www.jianshu.com/p/7cb729946c3c

1. new SpringApplication(Main.class), 初始化

1.1 source配置, primarySources

1.2 webApplicationType, 类型: servlet, none, reactive

1.3 配置初始化构造器, setInitializers((Collection) getSpringFactoriesInstances(ApplicationContextInitializer.class));

1.4 配置监听器, setListeners((Collection) getSpringFactoriesInstances(ApplicationListener.class));

1.5 找main方法的class

2. SpringApplication.run, 运行

2.1 准备environment, 发布 environmentPrepared -> BootstrapApplicationListener -> bootstrapServiceContext -> build ConfigurableApplicationContext -> run(也是springapplication, 创建context=AnnotationConfigApplicationContext, prepare context, ApplicationContextInitializer)

2.2 printBanner

2.3 createApplicationContext

2.4 prepareContext(load -> App的class将被注册, 生成bean definition)

2.5 refreshContext (startWebServer -> init servlet -> initWebApplicationContext -> refresh -> load bean definition -> 创建bean)

2.6 afterRefresh

2.7 listeners.started(context);

2.8 callRunners

2.9 listeners.running(context);

原文地址:https://www.cnblogs.com/drizzlewithwind/p/11442989.html