我是靠谱客的博主 哭泣树叶,这篇文章主要介绍SpringBoot设置接口超时时间,现在分享给大家,希望可以做个参考。

SpringBoot设置接口访问超时时间有两种方式

一、在配置文件application.properties中加了spring.mvc.async.request-timeout=20000,意思是设置超时时间为20000ms即20s,

二、还有一种就是在config配置类中加入:

复制代码
1
2
3
4
5
6
7
8
9
10
11
public class WebMvcConfig extends WebMvcConfigurerAdapter { @Override public void configureAsyncSupport(final AsyncSupportConfigurer configurer) { configurer.setDefaultTimeout(20000); configurer.registerCallableInterceptors(timeoutInterceptor()); } @Bean public TimeoutCallableProcessingInterceptor timeoutInterceptor() { return new TimeoutCallableProcessingInterceptor(); } }
登录后复制

以上就是SpringBoot设置接口超时时间的详细内容,更多请关注靠谱客其它相关文章!

最后

以上就是哭泣树叶最近收集整理的关于SpringBoot设置接口超时时间的全部内容,更多相关SpringBoot设置接口超时时间内容请搜索靠谱客的其他文章。

本图文内容来源于网友提供,作为学习参考使用,或来自网络收集整理,版权属于原作者所有。
点赞(88)

评论列表共有 0 条评论

立即
投稿
返回
顶部