• SpringBoot修改Servlet相关配置


    第一种方式在配置文件中进行修改

    1 server.port=8081
    2 server.servlet.context-path=/springboot
    3 server.tomcat.uri-encoding=utf-8
    4 #SpringBoot自动为我们配置DispatcherServlet,默认拦截"/"(所有请求,包括静态资源,但不拦截jsp请求,若要拦截
    5 # Jsp请求,修改配置为“/*”即可)
    6 spring.mvc.servlet.path=/*

    第二种方式在配置类中进行修改

     1 package cn.coreqi.config;
     2 
     3 import org.springframework.boot.web.server.WebServerFactoryCustomizer;
     4 import org.springframework.boot.web.servlet.server.ConfigurableServletWebServerFactory;
     5 import org.springframework.context.annotation.Bean;
     6 import org.springframework.context.annotation.Configuration;
     7 
     8 @Configuration
     9 public class ServletConfig {
    10 
    11     //SpringBoot1.x使用EmbeddedServletContainerCustomizer
    12     @Bean
    13     public WebServerFactoryCustomizer webServerFactoryCustomizer(){
    14         return new WebServerFactoryCustomizer<ConfigurableServletWebServerFactory>(){
    15             @Override
    16             public void customize(ConfigurableServletWebServerFactory factory) {
    17                 factory.setPort(8082);
    18             }
    19         };
    20     }
    21 }
  • 相关阅读:
    Zuul的核心源码解析
    基于Sentinel的服务保护
    Sentinel
    windows进行配置转发
    Hystrix断路器
    服务熔断Hystrix高级
    微服务架构的高并发问题
    Feign的高级配置
    倒排序原理和实例
    云计算技术的产生、概念、原理、应用和前景
  • 原文地址:https://www.cnblogs.com/fanqisoft/p/10335598.html
Copyright © 2020-2023  润新知