开发者社区 问答 正文

springboot 请求超时怎么设置呢? 400 报错

springboot 请求超时怎么设置呢? 400 报错

我配置10秒超时

 

然后我在方法里面休眠20秒 但20秒后就正常返回了 怎么没超时啊 

展开
收起
爱吃鱼的程序员 2020-06-05 12:22:35 1498 分享 版权
1 条回答
写回答
取消 提交回答
  • https://developer.aliyun.com/profile/5yerqm5bn5yqg?spm=a2c6h.12873639.0.0.6eae304abcjaIB

    试试这个 

    public class WebMvcConfig extends WebMvcConfigurerAdapter {
        @Override
        public void configureAsyncSupport(final AsyncSupportConfigurer configurer) {
            configurer.setDefaultTimeout(10000);
            configurer.registerCallableInterceptors(timeoutInterceptor());
        }
        @Bean
        public TimeoutCallableProcessingInterceptor timeoutInterceptor() {
            return new TimeoutCallableProcessingInterceptor();
        }
    }
     

    2020-06-05 12:22:47
    赞同 展开评论