惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

I
InfoQ
G
Google Developers Blog
Engineering at Meta
Engineering at Meta
月光博客
月光博客
博客园 - 聂微东
博客园 - Franky
奇客Solidot–传递最新科技情报
奇客Solidot–传递最新科技情报
有赞技术团队
有赞技术团队
A
About on SuperTechFans
Microsoft Azure Blog
Microsoft Azure Blog
Blog — PlanetScale
Blog — PlanetScale
U
Unit 42
T
Tailwind CSS Blog
Cyber Security Advisories - MS-ISAC
Cyber Security Advisories - MS-ISAC
云风的 BLOG
云风的 BLOG
S
SegmentFault 最新的问题
F
Fortinet All Blogs
H
Help Net Security
J
Java Code Geeks
酷 壳 – CoolShell
酷 壳 – CoolShell
博客园 - 叶小钗
L
LangChain Blog
Martin Fowler
Martin Fowler
N
Netflix TechBlog - Medium

博客园 - Matt_Cheng

AI编码实践 对于动态注册的bean,aop会生效吗? LLM VSCode快捷命令 图平台技术点 常用CMD命令 jupyter安装与使用 数据结构文章收藏 使用beeline访问hive Java线程异常处理 属性文件加载 node.js待实践项目 docker命令 IDEA环境配置与快捷命令 Spring MVC 使用介绍(十六)数据验证 (三)分组、自定义、跨参数、其他 Spring MVC 使用介绍(十五)数据验证 (二)依赖注入与方法级别验证 Spring MVC 使用介绍(十四)文件上传下载 2018年年终总结
spring boot问题记录
Matt_Cheng · 2021-06-08 · via 博客园 - Matt_Cheng

一、静态文件配置

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