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设置接口超时时间内容请搜索靠谱客的其他文章。
本图文内容来源于网友提供,作为学习参考使用,或来自网络收集整理,版权属于原作者所有。
发表评论 取消回复