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

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

创新互联公司2013年至今,是专业互联网技术服务公司,拥有项目网站制作、网站建设网站策划,项目实施与项目整合能力。我们以让每一个梦想脱颖而出为使命,1280元宝清做网站,已为上家服务,为宝清各地企业和个人服务,联系电话:13518219792

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


文章标题:SpringBoot设置接口超时时间的方法
分享链接:http://ybzwz.com/article/josppo.html