我有一个由Java配置支持的Spring MVC应用程序,我想为所有涉及Callable <>接口的异步调用设置默认超时.例如,考虑这样的控制器方法:
@RequestMapping
public Callable<String> doSmth() {
return () -> {
return "myview";
}
}
Run Code Online (Sandbox Code Playgroud)
我希望有一个控制器(每个应用程序)控制器有多少时间在请求超时之前完成它的工作.
我想有一个Java配置的例子,而不是xml
您可以通过扩展WebMvcConfigurerAdapter和覆盖来实现configureAsyncSupport:
@Configuration
//other annotations if needed
public class WebConfig extends WebMvcConfigurerAdapter {
@Override
public void configureAsyncSupport(AsyncSupportConfigurer configurer) {
configurer.setDefaultTimeout(100000); //in milliseconds
super.configureAsyncSupport(configurer);
}
Run Code Online (Sandbox Code Playgroud)
或直接在RequestMappingHandlerAdapter.
| 归档时间: |
|
| 查看次数: |
6615 次 |
| 最近记录: |