SpringBoot设置接口超时时间的方法

发布时间:2020-10-12 17:11:11 作者:小新
来源:亿速云 阅读:1359

小编给大家分享一下SpringBoot设置接口超时时间的方法,希望大家阅读完这篇文章后大所收获,下面让我们一起去探讨吧!

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

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

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

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设置接口超时时间的方法有了一定的了解,想了解更多相关知识,欢迎关注亿速云行业资讯频道,感谢各位的阅读!

推荐阅读:
  1. 怎么设置session的超时时间
  2. php如何设置执行超时时间?

免责声明:本站发布的内容(图片、视频和文字)以原创、转载和分享为主,文章观点不代表本网站立场,如果涉及侵权请联系站长邮箱:is@yisu.com进行举报,并提供相关证据,一经查实,将立刻删除涉嫌侵权内容。

springboot bo

上一篇:虚拟主机怎么升级

下一篇:虚拟主机速度快不快

相关阅读

您好,登录后才能下订单哦!

密码登录
登录注册
其他方式登录
点击 登录注册 即表示同意《亿速云用户服务条款》