zoukankan      html  css  js  c++  java
  • SpringBoot定制修改Servlet容器

    1.如何修改Servlet容器的相关配置:

    第一种:在application.properties中修改和server有关的配置(ServerProperties提供);

    server.port=8081
    server.context‐path=/crud
    server.tomcat.uri‐encoding=UTF‐8
    //通用的Servlet容器设置
    server.xxx
    //Tomcat的设置
    server.tomcat.xxx

    第二种:编写一个EmbeddedServletContainerCustomizer(嵌入式Servlet容器定制器);

    @Bean

    public EmbeddedServletContainerCustomizer embeddedServletContainerCustomizer(){

      return new EmbeddedServletContainerCustomizer() {

        //定制嵌入式的Servlet容器相关的规则

        @Override

        public void customize(ConfigurableEmbeddedServletContainer container) {//传入一个可配置的嵌入式容器

          container.setPort(8083);

        }

      };

    }

    2.如何更改默认servlet容器

    该默认Tomcat为Jetty,也可以更改为Undertow

    <!‐‐ 引入web模块 ‐‐>

    <dependency>
    <groupId>org.springframework.boot</groupId>
    <artifactId>spring‐boot‐starter‐web</artifactId>
    <exclusions>
    <exclusion>

    <!‐‐去除其Tomcat容器‐‐>
    <artifactId>spring‐boot‐starter‐tomcat</artifactId>
    <groupId>org.springframework.boot</groupId>
    </exclusion>
    </exclusions>
    </dependency>
    <!‐‐引入其他的Servlet容器‐‐>
    <dependency>
    <artifactId>spring‐boot‐starter‐jetty</artifactId>
    <groupId>org.springframework.boot</groupId>
    </dependency>

  • 相关阅读:
    CCF计算机职业资格认证考试 201809-2 买菜
    【CodeVS3013】单词背诵
    【CodeVS3304】水果姐逛水果街Ⅰ
    【CodeVS4246】奶牛的身高
    【hdu1247】Hat’s Words
    【CodeVS4189】字典
    【CodeVS4244】平衡树练习
    【poj3264】Balanced Lineup
    【树状数组】
    【CodeVS1163】访问艺术馆
  • 原文地址:https://www.cnblogs.com/brxHqs/p/10271488.html
Copyright © 2011-2022 走看看