一般使用SpringBoot开发应用程序都是使用的tomcat 稍微注意点性能就使用undertow,配置支持https请求常用nginx来做代理,直接用SpringBoot配置还是很少的,八成用不到,就怕需要用到的时候又不能及时弄出来,于是记录一下。
使用的SpringBoot版本
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>2.0.5.RELEASE</version>
<relativePath/> <!-- lookup parent from repository -->
</parent>
直接使用tomcat的话 默认就好
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
<!-- spring-boot-starter-web 包含了这个的-->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-tomcat</artifactId>
</dependency>
使用jetty
<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-jetty</artifactId>
</dependency>
使用undertow
<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

本文介绍了在SpringBoot中如何选择内置服务器(tomcat、jetty、undertow),并提供了各服务器的HTTPS配置方法,包括使用Nginx做代理。同时,提到了http2的启用以及不同服务器的http到https的重定向配置策略。
最低0.47元/天 解锁文章
720

被折叠的 条评论
为什么被折叠?



