Home  >  Article  >  Java  >  SpringBoot sets interface timeout

SpringBoot sets interface timeout

(*-*)浩
(*-*)浩forward
2019-08-07 16:53:288263browse

SpringBoot has two ways to set the interface access timeout period

SpringBoot sets interface timeout

1. Add it to the configuration file application.properties Spring.mvc.async.request-timeout=20000, which means setting the timeout to 20000ms or 20s,

Second, there is another way to add:

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();
	}
}
to the config configuration class

The above is the detailed content of SpringBoot sets interface timeout. For more information, please follow other related articles on the PHP Chinese website!

Statement:
This article is reproduced at:csdn.net. If there is any infringement, please contact admin@php.cn delete