增加 SpringUtils.isVirtual 方法

This commit is contained in:
数据小王子 2024-02-29 10:30:11 +08:00
parent 651da9a92a
commit 773e257fa1
2 changed files with 8 additions and 1 deletions

View File

@ -14,7 +14,8 @@ import java.util.concurrent.Executor;
/**
* 异步配置
*
* <p>
* 如果未使用虚拟线程则生效
* @author Lion Li
*/
@ConditionalOnProperty(prefix = "spring.threads.virtual", name = "enabled", havingValue = "false")

View File

@ -3,7 +3,9 @@ package com.ruoyi.common.core.utils;
import cn.hutool.extra.spring.SpringUtil;
import org.springframework.aop.framework.AopContext;
import org.springframework.beans.factory.NoSuchBeanDefinitionException;
import org.springframework.boot.autoconfigure.thread.Threading;
import org.springframework.context.ApplicationContext;
import org.springframework.core.env.Environment;
import org.springframework.stereotype.Component;
/**
@ -98,4 +100,8 @@ public final class SpringUtils extends SpringUtil
return StringUtils.isNotEmpty(activeProfiles) ? activeProfiles[0] : null;
}
public static boolean isVirtual() {
return Threading.VIRTUAL.isActive(getBean(Environment.class));
}
}