SpringBoot开启http2

http2

#1

SpringBoot开启http2

http2 的相关信息 https://baike.baidu.com/item/HTTP%202.0/12520156?fr=aladdin

配置

http2必须使用ssl

server:
  port: 443
  servlet:
    context-path: /
  ssl:
    enabled: true
    key-store: classpath:ssl/localhost.keystore
    key-store-type: PKCS12
    key-store-password: 123456
  http2:
    # 开启http2
    enabled: true

使用Undertow容器

使用默认的Tomcat未能成功开启http2,是我的打开方式有问题?:sweat:

<dependency>
	<groupId>org.springframework.boot</groupId>
	<artifactId>spring-boot-starter-web</artifactId>
	<exclusions>
		<exclusion>
			<groupId>org.springframework.boot</groupId>
			<artifactId>spring-boot-starter-tomcat</artifactId>
		</exclusion>
	</exclusions>
</dependency>
<dependency>
	<groupId>org.springframework.boot</groupId>
	<artifactId>spring-boot-starter-undertow</artifactId>
</dependency>

通过浏览器查看http协议的版本

image