介绍
小编给大家分享一下SpringBoot设置接口超时时间的方法,希望大家阅读完这篇文章后大所收获、下面让我们一起去探讨吧!
<强> SpringBoot设置接口访问超时时间有两种方式强>
一、在配置文件application.properties中加了spring.mvc.async。请求超时=20000,意思是设置超时时间为20000 ms即20年代,
二,还有一种就是在配置配置类中加入:
公共类WebMvcConfig延伸WebMvcConfigurerAdapter { @Override 公共空间configureAsyncSupport(最终AsyncSupportConfigurer配置){ configurer.setDefaultTimeout (20000); configurer.registerCallableInterceptors (timeoutInterceptor ()); } @ bean 公共TimeoutCallableProcessingInterceptor timeoutInterceptor () { 返回新TimeoutCallableProcessingInterceptor (); } }
看完了这篇文章,相信你对SpringBoot设置接口超时时间的方法有了一定的了解,想了解更多相关知识,欢迎关注行业资讯频道,感谢各位的阅读!