fix 异步任务线程池使用错误

This commit is contained in:
dongleitao 2023-03-09 17:48:28 +08:00
parent a5ee33b559
commit de5525a3ec

View File

@ -8,10 +8,10 @@ import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.context.annotation.Configuration; import org.springframework.context.annotation.Configuration;
import org.springframework.scheduling.annotation.AsyncConfigurerSupport; import org.springframework.scheduling.annotation.AsyncConfigurerSupport;
import org.springframework.scheduling.annotation.EnableAsync; import org.springframework.scheduling.annotation.EnableAsync;
import org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor;
import java.util.Arrays; import java.util.Arrays;
import java.util.concurrent.Executor; import java.util.concurrent.Executor;
import java.util.concurrent.ScheduledExecutorService;
/** /**
* 异步配置 * 异步配置
@ -23,15 +23,15 @@ import java.util.concurrent.ScheduledExecutorService;
public class AsyncConfig extends AsyncConfigurerSupport { public class AsyncConfig extends AsyncConfigurerSupport {
@Autowired @Autowired
@Qualifier("scheduledExecutorService") @Qualifier("threadPoolTaskExecutor")
private ScheduledExecutorService scheduledExecutorService; private ThreadPoolTaskExecutor threadPoolTaskExecutor;
/** /**
* 自定义 @Async 注解使用系统线程池 * 自定义 @Async 注解使用系统线程池
*/ */
@Override @Override
public Executor getAsyncExecutor() { public Executor getAsyncExecutor() {
return scheduledExecutorService; return threadPoolTaskExecutor;
} }
/** /**