From 377f7c249f111f51d257e58e69cd1bda45c7beb0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=96=AF=E7=8B=82=E7=9A=84=E7=8B=AE=E5=AD=90Li?= <15040126243@163.com> Date: Wed, 21 Feb 2024 13:32:18 +0800 Subject: [PATCH] =?UTF-8?q?update=20=E4=BC=98=E5=8C=96=20AsyncConfig=20?= =?UTF-8?q?=E8=99=9A=E6=8B=9F=E7=BA=BF=E7=A8=8B=E5=90=8D=E7=A7=B0=E6=94=AF?= =?UTF-8?q?=E6=8C=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/org/dromara/common/core/config/AsyncConfig.java | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/ruoyi-common/ruoyi-common-core/src/main/java/org/dromara/common/core/config/AsyncConfig.java b/ruoyi-common/ruoyi-common-core/src/main/java/org/dromara/common/core/config/AsyncConfig.java index 66eea66c..cd01e33d 100644 --- a/ruoyi-common/ruoyi-common-core/src/main/java/org/dromara/common/core/config/AsyncConfig.java +++ b/ruoyi-common/ruoyi-common-core/src/main/java/org/dromara/common/core/config/AsyncConfig.java @@ -5,7 +5,7 @@ import org.dromara.common.core.exception.ServiceException; import org.dromara.common.core.utils.SpringUtils; import org.springframework.aop.interceptor.AsyncUncaughtExceptionHandler; import org.springframework.boot.autoconfigure.AutoConfiguration; -import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty; +import org.springframework.core.task.VirtualThreadTaskExecutor; import org.springframework.scheduling.annotation.AsyncConfigurer; import java.util.Arrays; @@ -18,7 +18,6 @@ import java.util.concurrent.Executor; * * @author Lion Li */ -@ConditionalOnProperty(prefix = "spring.threads.virtual", name = "enabled", havingValue = "false") @AutoConfiguration public class AsyncConfig implements AsyncConfigurer { @@ -27,6 +26,9 @@ public class AsyncConfig implements AsyncConfigurer { */ @Override public Executor getAsyncExecutor() { + if(SpringUtils.isVirtual()) { + return new VirtualThreadTaskExecutor("async-"); + } return SpringUtils.getBean("scheduledExecutorService"); }