小編給大家分享一下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設置接口超時時間的方法有了一定的了解,想了解更多相關知識,歡迎關注億速云行業資訊頻道,感謝各位的閱讀!
免責聲明:本站發布的內容(圖片、視頻和文字)以原創、轉載和分享為主,文章觀點不代表本網站立場,如果涉及侵權請聯系站長郵箱:is@yisu.com進行舉報,并提供相關證據,一經查實,將立刻刪除涉嫌侵權內容。