Home > Java > javaTutorial > SpringBoot sets interface timeout

SpringBoot sets interface timeout

(*-*)浩
Release: 2019-08-07 16:53:28
forward
8346 people have browsed it

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:

1

2

3

4

5

6

7

8

9

10

11

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();

    }

}

Copy after login
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!

Related labels:
source:csdn.net
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template