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>

SpringBoot定制修改Servlet容器的更多相关文章

  1. java框架之SpringBoot(8)-嵌入式Servlet容器

    前言 SpringBoot 默认使用的嵌入式 Servlet 容器为 Tomcat,通过依赖关系就可以看到: 问题: 如何定制和修改 Servlet 容器相关配置? SpringBoot 能否支持其它 ...

  2. springboot(八) 嵌入式Servlet容器自动配置原理和容器启动原理

    1.嵌入式Servlet容器自动配置原理 1.1 在spring-boot-autoconfigure-1.5.9.RELEASE.jar => springboot自动配置依赖 jar包下,E ...

  3. SpringBoot(七) -- 嵌入式Servlet容器

    一.嵌入式Servlet容器 在传统的开发中,我们在完成开发后需要将项目打成war包,在外部配置好TomCat容器,而这个TomCat就是Servlet容器.在使用SpringBoot开发时,我们无需 ...

  4. SpringBoot配置嵌入式Servlet容器

    1).如何定制和修改Servlet容器的相关配置: 1.修改和server有关的配置(ServerProperties[也是EmbeddedServletContainerCustomizer]): ...

  5. springboot外置的Servlet容器

    嵌入式Servlet容器:应用打成可执行的jar ​ 优点:简单.便携: ​ 缺点:默认不支持JSP.优化定制比较复杂(使用定制器[ServerProperties.自定义EmbeddedServle ...

  6. 尚硅谷springboot学习25-嵌入式Servlet容器

    SpringBoot默认使用Tomcat作为嵌入式的Servlet容器:

  7. springboot(七) 配置嵌入式Servlet容器

    github代码地址:https://github.com/showkawa/springBoot_2017/tree/master/spb-demo/spb-brian-query-service ...

  8. SpringBoot源码学习系列之嵌入式Servlet容器

    目录 1.博客前言简单介绍 2.定制servlet容器 3.变换servlet容器 4.servlet容器启动原理 SpringBoot源码学习系列之嵌入式Servlet容器启动原理 @ 1.博客前言 ...

  9. SpringBoot起飞系列-配置嵌入式Servlet容器(八)

    一.前言 springboot中默认使用的是tomcat容器,也叫做嵌入式的servlet容器.因为它和我们平常使用的tomcat容器不一样,这个tomcat直接嵌入到的springboot,平常我们 ...

随机推荐

  1. Python基础之Python分类

    python环境 编译型: 一次性将所有程序编译成二级制文件,开发效率极低,因为一旦出现BUG所有的程序需要全部重新编译 缺点: 开发效率低,不能跨平台 优点: 执行速度快 解释型: 当程序执行时,一 ...

  2. laravel 自定义常量的方法

    注意:laravel版本为5.1  第一种方法 在本地可以用 我上传到服务器发现用不了  有待解决 第二种方法  在本地可以用 上传服务器后 要把 constants.php   文件权限改为 755 ...

  3. ubuntu后台运行命令

    参考 https://blog.csdn.net/shaozg168/article/details/6979337 nohup ./test.sh &

  4. LibreOJ 6282. 数列分块入门 6

    题目链接:https://loj.ac/problem/6282 参考博客:http://www.cnblogs.com/stxy-ferryman/p/8560551.html 这里如果用数组的话元 ...

  5. 事务、cookie、session操作

    事务 import os if __name__ == '__main__': os.environ.setdefault('DJANGO_SETTINGS_MODULE','BMS.settings ...

  6. leecode 978. Longest Turbulent Subarray(最长连续波动序列,DP or 滚动数组)

    传送门:点我 978. Longest Turbulent Subarray A subarray A[i], A[i+1], ..., A[j] of A is said to be turbule ...

  7. DBVIS工具 管理数据库链接

  8. Balanced Numbers (数位DP)

    Balanced Numbers https://vjudge.net/contest/287810#problem/K Balanced numbers have been used by math ...

  9. 【Linux 线程】线程同步《二》

    1.读写锁 与互斥量类似,但读写锁允许更高的并行性.其特性为:写独占,读共享. 读写锁状态: 一把读写锁具备三种状态: (1)读模式下加锁状态 (读锁) (2)写模式下加锁状态 (写锁) (3)不加锁 ...

  10. 【C++ const_cast强制转换】