一、在配置文件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设置接口超时时间的详细内容。
