如何定制和修改Servlet容器的相关配置--spring boot
2020-02-12 12:16
507 查看
前言:SpringBoot默认使用Tomcat作为嵌入式的Servlet容器
如何定制和修改Servlet容器的相关配置
1、修改和server有关的配置(ServerProperties【也是EmbeddedServletContainerCustomizer】)
server.port=8081 server.context-path=/crud server.tomcat.uri-encoding=UTF-8 //通用的Servlet容器设置 server.xxx //Tomcat的设置 server.tomcat.xxx
2、编写一个EmbeddedServletContainerCustomizer:嵌入式的Servlet容器的定制器;来修改Servlet容器的配置
在这里插入代码片@Bean //一定要将这个定制器加入到容器中 public EmbeddedServletContainerCustomizer embeddedServletContainerCustomizer(){ return new EmbeddedServletContainerCustomizer() { //定制嵌入式的Servlet容器相关的规则 @Override public void customize(ConfigurableEmbeddedServletContainer container) { container.setPort(8083); } }; }
格言:不驰于空想,不骛于虚声
- 点赞
- 收藏
- 分享
- 文章举报
相关文章推荐
- 十、SpringBoot——Servlet容器配置&相关原理(tomcat)
- Spring Boot (七)——容器的相关配置
- SpringBoot基础——SpringBoot配置嵌入式Servlet容器
- 如何将spring boot application.properties修改成为spring boot配置文件
- spring boot 1.5.4 web容器定制(端口号等修改)方法
- 【spring-boot】spring-boot-配置嵌入式Servlet容器学习
- Spring Boot项目中如何定制servlet-filters
- SpringBoot中配置嵌入式Servlet容器
- spring boot 如何添加配置到ioc容器中
- Spring Boot 学习笔记(五) 配置Servlet容器
- 三、spring boot 1.5.4 web容器定制(端口号等修改)
- 在部署到Servlet容器之前,如何生成包含SpringBoot的War文件
- SpringBoot之配置嵌入式Servlet容器
- [原创]java WEB学习笔记98:Spring学习---Spring Bean配置及相关细节:如何在配置bean,Spring容器(BeanFactory,ApplicationContext),如何获取bean,属性赋值(属性注入,构造器注入),配置bean细节(字面值,包含特殊字符,引用bean,null值,集合属性list map propert),util 和p 命名空间
- 常规容器下SpringBootServletInitializer如何实现web.xml作用解析
- 常规容器下SpringBootServletInitializer如何实现web.xml作用解析
- SpringBoot学习笔记(四) SpringBoot Web相关的自动配置
- spring boot web相关配置
- SpringBoot如何导入自定义配置的yml文件
- SpringBoot之在Servlet2.5容器中部署war应用