增加 SpringUtils.isVirtual 方法
This commit is contained in:
parent
651da9a92a
commit
773e257fa1
@ -14,7 +14,8 @@ import java.util.concurrent.Executor;
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* 异步配置
|
* 异步配置
|
||||||
*
|
* <p>
|
||||||
|
* 如果未使用虚拟线程则生效
|
||||||
* @author Lion Li
|
* @author Lion Li
|
||||||
*/
|
*/
|
||||||
@ConditionalOnProperty(prefix = "spring.threads.virtual", name = "enabled", havingValue = "false")
|
@ConditionalOnProperty(prefix = "spring.threads.virtual", name = "enabled", havingValue = "false")
|
||||||
|
@ -3,7 +3,9 @@ package com.ruoyi.common.core.utils;
|
|||||||
import cn.hutool.extra.spring.SpringUtil;
|
import cn.hutool.extra.spring.SpringUtil;
|
||||||
import org.springframework.aop.framework.AopContext;
|
import org.springframework.aop.framework.AopContext;
|
||||||
import org.springframework.beans.factory.NoSuchBeanDefinitionException;
|
import org.springframework.beans.factory.NoSuchBeanDefinitionException;
|
||||||
|
import org.springframework.boot.autoconfigure.thread.Threading;
|
||||||
import org.springframework.context.ApplicationContext;
|
import org.springframework.context.ApplicationContext;
|
||||||
|
import org.springframework.core.env.Environment;
|
||||||
import org.springframework.stereotype.Component;
|
import org.springframework.stereotype.Component;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -98,4 +100,8 @@ public final class SpringUtils extends SpringUtil
|
|||||||
return StringUtils.isNotEmpty(activeProfiles) ? activeProfiles[0] : null;
|
return StringUtils.isNotEmpty(activeProfiles) ? activeProfiles[0] : null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static boolean isVirtual() {
|
||||||
|
return Threading.VIRTUAL.isActive(getBean(Environment.class));
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user