zoukankan      html  css  js  c++  java
  • spring boot问题记录

    一、静态文件配置

    spring boot 2.3.5.RELEASE

    1、默认情况下,静态文件映射模板为:/**,映射路径为:"classpath:/META-INF/resources/", "classpath:/resources/", "classpath:/static/", "classpath:/public/",见 WebMvcProperties、ResourceProperties

    2、默认配置可通过配置文件覆盖

    spring.mvc.static-path-pattern=/abc/**
    spring.resources.static-locations=classpath:/static/

    3、当使用@EnableWebMvc定义web配置时,默认配置或配置文件覆盖的配置失效,即使类无方法,此时须使用代码指定,

    @Configuration
    @EnableWebMvc
    public class WebConfig implements WebMvcConfigurer  {
    
        @Override
        public void addResourceHandlers(ResourceHandlerRegistry registry) {
    
            registry.addResourceHandler("/**").addResourceLocations("classpath:/static/");
        }
    }

    4、在指定映射路径时,须以‘/’结尾,如"classpath:/static/",而非"classpath:/static",否则会失效

    二、OpenFeign超时配置

    spring cloud 2020.0.3  代码见https://github.com/matt-jcheng/spring-learning

    1、OpenFeign超时配置如下

    feign.client.config.default.logger-level = full
    feign.client.config.default.connect-timeout=5000
    feign.client.config.default.read-timeout=10000
    feign.client.config.StoreClient.read-timeout=10000

    2、如引入断路器,还需配置断路器超时

    feign.circuitbreaker.enabled=true
    resilience4j.timelimiter.configs.default.timeout-duration = 10000

    ps:hytrix已停止更新,spring cloud对断路器进行抽象,支持多种实现,如spring-cloud-starter-circuitbreaker-resilience4j

  • 相关阅读:
    类成员函数的重载、覆盖和隐藏区别 (C++)(转)
    man时括号里的数字是啥意思
    Redis事务
    功能接口
    持久化方式
    宿主
    路由
    静态文件
    Log4Net 配置
    Redis命令与配置
  • 原文地址:https://www.cnblogs.com/MattCheng/p/14863950.html
Copyright © 2011-2022 走看看