Spring Boot Server容器配置
2018-01-25 09:37
411 查看
参数配置容器
server.xx开头的是所有servlet容器通用的配置,server.tomcat.xx开头的是tomcat特有的参数,其它类似。所有参数绑定配置类:org.springframework.boot.autoconfigure.web.ServerProperties
代码配置容器
除了利用上面的参数来自动配置servlet容器,还可以通过代码的方式。可以直接实现EmbeddedServletContainerCustomizer这个接口,ServerProperties也是实现这个接口的。@ConfigurationProperties(prefix = "server", ignoreUnknownFields = true) public class ServerProperties implements EmbeddedServletContainerCustomizer, EnvironmentAware, Ordered { ...
当然如果是Tomcat、Jetty、Undertow也可以使用下面对应的特定的容器工厂类。
// Jetty org.springframework.boot.context.embedded.jetty.JettyEmbeddedServletContainerFactory // Tomcat org.springframework.boot.context.embedded.tomcat.TomcatEmbeddedServletContainerFactory // Undertow org.springframework.boot.context.embedded.undertow.UndertowEmbeddedServletContainerFactory
替换Tomcat
spring-boot-starter-web brings Tomcat with spring-boot-starter-tomcat, but spring-boot-starter-jetty and spring-boot-starter-undertow can be used instead.spring-boot-starter-web自动携带了tomcat依赖,但也可以替换成jetty和undertow,下面是一个替换jetty的示例。
<dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-web</artifactId> <exclusions> <!-- Exclude the Tomcat dependency --> <exclusion> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-tomcat</artifactId> </exclusion> </exclusions> </dependency> <!-- Use Jetty instead --> <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-jetty</artifactId> </dependency>
推荐阅读
干货:2TB架构师四阶段视频教程面经:史上最全Java多线程面试题及答案
面经:史上最全阿里高级Java面试题
面经:史上最全Spring面试题
教程:最全Spring Boot全套视频教程
书籍:进阶Java架构师必看的15本书
工具:推荐一款在线创作流程图、思维导图软件
分享Java干货,高并发编程,热门技术教程,微服务及分布式技术,架构设计,区块链技术,人工智能,大数据,Java面试题,以及前沿热门资讯等。
相关文章推荐
- SpringBoot配置属性之Server
- Spring Boot的Server配置信息
- Spring Boot中的容器配置和SSL支持
- Spring Boot 实践折腾记(六):Spring Boot中的容器配置和SSL支持
- SpringBoot深入(一)--SpringBoot内置web容器及配置
- 【spring-boot】spring-boot-配置嵌入式Servlet容器学习
- spring boot实战(第七篇)内嵌容器tomcat配置
- Spring Boot Server配置描述
- spring boot实战(第七篇)内嵌容器tomcat配置
- Spring Boot Server 配置
- SpringBoot配置属性之Server
- spring boot实战之内嵌容器tomcat配置
- spring boot实战(第七篇)内嵌容器tomcat配置
- SpringBoot配置属性之Server
- spring-boot配置文件-Server(中文翻译)
- IntelliJ IDEA 配置Gradle运行SpringBoot Web项目(tomcat容器)
- SpringBoot配置属性之Server(二)
- SpringBoot配置属性之Server
- Spring Boot 项目在外部容器中运行的配置
- Spring-boot 配置Jetty 容器