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

SpringBoot设置接口超时时间-LMLPHP

一、在配置文件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设置接口超时时间的详细内容,更多请关注Work网其它相关文章!

09-03 13:47