SpringBoot设置接口超时时间

SpringBoot设置接口超时时间,第1张

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设置接口超时时间的详细内容,

欢迎分享,转载请注明来源:内存溢出

原文地址: https://outofmemory.cn/langs/690004.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2022-04-21
下一篇 2022-04-21

发表评论

登录后才能评论

评论列表(0条)

保存