继承org.springframework.scheduling.annotation.AsyncConfigurer 重写其getAsyncExecutor方法,从而实现@Async默认线程池的配置
@Slf4j
@EnableAsync
@Configuration
@RequiredArgsConstructor
public class AsyncConfig implements AsyncConfigurer {
private final ExecutorService threadPoolExecutor;
@Override
public Executor getAsyncExecutor() {
return threadPoolExecutor;
}
@Override
public AsyncUncaughtExceptionHandler getAsyncUncaughtExceptionHandler() {
return (arg0, arg1, arg2) -> {
log.error("Async uncaught exception,throwable:{},method:{},params:{}", arg0,arg1,arg2);
};
}
}
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)