依赖pom.xml
配置文件bootstrap.yml
配置源码
/**
*
* 使用方式:
* 类上添加@Component
* 类方法上添加@Async
*
* Description: 异步执行配置类
* @author Vander
* @author 2018年4月26日
* @version 0.8
*/
@Configuration
@EnableAsync
public class TaskExecutorConfig implements AsyncConfigurer{
@Override
public Executor getAsyncExecutor() {
ThreadPoolTaskExecutor taskExecutor = new ThreadPoolTaskExecutor();
//TODO 后续配置文件注入参数
taskExecutor.setCorePoolSize(5);
taskExecutor.setMaxPoolSize(10);
taskExecutor.setQueueCapacity(Integer.MAX_VALUE);
taskExecutor.initialize();
return taskExecutor;
}
@Override
public AsyncUncaughtExceptionHandler getAsyncUncaughtExceptionHandler() {
return null;
}
}