心悦俱乐部官方网站怎么做任务,网站备案 暂住证,郑州网络推广服务,网页设计教程文字与图片springboot定制嵌入式的servlet容器 修改容器配置 有两种方式可以修改容器的配置 可以直接在配置文件中修改和server有关的配置 server.port8081
server.tomcat.uri-encodingUTF-8//通用的Servlet容器设置
server.xxx
//指定Tomcat的设置
server.tomcat.xxx编写一个EmbeddedSer… springboot定制嵌入式的servlet容器 修改容器配置 有两种方式可以修改容器的配置 可以直接在配置文件中修改和server有关的配置 server.port8081
server.tomcat.uri-encodingUTF-8//通用的Servlet容器设置
server.xxx
//指定Tomcat的设置
server.tomcat.xxx编写一个EmbeddedServletContainerCustomizer组件来进行嵌入式的Servlet容器的定制器来修改Servlet容器的配置 Beanpublic EmbeddedServletContainerCustomizer embeddedServletContainerCustomizer(){ return new EmbeddedServletContainerCustomizer() { //定制嵌入式的Servlet容器相关的规则 Override public void customize(ConfigurableEmbeddedServletContainer container) { container.setPort(8081); } };} 其实对于server的配置所采用的ServerProperties也是一个EmbeddedServletContainerCustomizer ConfigurationProperties(prefix server, ignoreUnknownFields true)public class ServerProperties implements EmbeddedServletContainerCustomizer, EnvironmentAware, Ordered { 替换为其他的servlet容器 默认springboot使用的是tomcat作为servlet容器可以将servlet容器替换为jetty !-- 排除tomcat --dependency groupIdorg.springframework.boot/groupId artifactIdspring-boot-starter-web/artifactId exclusions exclusion groupIdorg.springframework.boot/groupId artifactIdspring-boot-starter-tomcat/artifactId /exclusion /exclusions/dependency!-- 引入jetty --dependency groupIdorg.springframework.boot/groupId artifactIdspring-boot-starter-jetty/artifactId/dependency https://zhhll.icu/2021/框架/springboot/基础/6.定制嵌入式的servlet容器/ 本文由 mdnice 多平台发布