From 71d1d7bd7787ec389f146a924dba9295d8dfbe6f Mon Sep 17 00:00:00 2001 From: dataprince Date: Sun, 14 Jan 2024 10:35:31 +0800 Subject: [PATCH] =?UTF-8?q?=E5=90=AF=E7=94=A8=E8=99=9A=E6=8B=9F=E7=BA=BF?= =?UTF-8?q?=E7=A8=8B=E5=90=8E=EF=BC=8C=E4=B8=8D=E5=86=8D=E9=9C=80=E8=A6=81?= =?UTF-8?q?=E5=8E=9F=E6=9D=A5=E7=9A=84=E7=BA=BF=E7=A8=8B=E6=B1=A0=E5=8A=9F?= =?UTF-8?q?=E8=83=BD=E4=BA=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- pom.xml | 2 +- .../src/main/resources/application.yml | 9 ------ .../common/core/config/ApplicationConfig.java | 3 +- .../ruoyi/common/core/config/AsyncConfig.java | 3 +- .../common/core/config/ThreadPoolConfig.java | 17 ----------- .../properties/ThreadPoolProperties.java | 30 ------------------- 6 files changed, 5 insertions(+), 59 deletions(-) delete mode 100644 ruoyi-common/ruoyi-common-core/src/main/java/com/ruoyi/common/core/config/properties/ThreadPoolProperties.java diff --git a/pom.xml b/pom.xml index b49ffb3..9a13a86 100644 --- a/pom.xml +++ b/pom.xml @@ -44,7 +44,7 @@ 0.2.0 5.8.24 3.25.2 - 2.2.4 + 2.2.7 2.14.4 3.2.0 4.3.6 diff --git a/ruoyi-admin/src/main/resources/application.yml b/ruoyi-admin/src/main/resources/application.yml index a26eb42..ab54a02 100644 --- a/ruoyi-admin/src/main/resources/application.yml +++ b/ruoyi-admin/src/main/resources/application.yml @@ -245,15 +245,6 @@ xss: # 匹配链接 urlPatterns: /system/*,/monitor/*,/tool/*,/demo/* -# 全局线程池相关配置 -thread-pool: - # 是否开启线程池 - enabled: false - # 队列最大长度 - queueCapacity: 128 - # 线程池维护线程所允许的空闲时间 - keepAliveSeconds: 300 - # 分布式锁 lock4j 全局配置 lock4j: # 获取分布式锁超时时间,默认为 3000 毫秒 diff --git a/ruoyi-common/ruoyi-common-core/src/main/java/com/ruoyi/common/core/config/ApplicationConfig.java b/ruoyi-common/ruoyi-common-core/src/main/java/com/ruoyi/common/core/config/ApplicationConfig.java index 0bfa503..f0a482c 100644 --- a/ruoyi-common/ruoyi-common-core/src/main/java/com/ruoyi/common/core/config/ApplicationConfig.java +++ b/ruoyi-common/ruoyi-common-core/src/main/java/com/ruoyi/common/core/config/ApplicationConfig.java @@ -2,6 +2,7 @@ package com.ruoyi.common.core.config; import org.springframework.boot.autoconfigure.AutoConfiguration; import org.springframework.context.annotation.EnableAspectJAutoProxy; +import org.springframework.scheduling.annotation.EnableAsync; /** * 程序注解配置 @@ -11,7 +12,7 @@ import org.springframework.context.annotation.EnableAspectJAutoProxy; @AutoConfiguration // 表示通过aop框架暴露该代理对象,AopContext能够访问 @EnableAspectJAutoProxy(exposeProxy = true) -// 指定要扫描的Mapper类的包的路径 +@EnableAsync(proxyTargetClass = true) public class ApplicationConfig { diff --git a/ruoyi-common/ruoyi-common-core/src/main/java/com/ruoyi/common/core/config/AsyncConfig.java b/ruoyi-common/ruoyi-common-core/src/main/java/com/ruoyi/common/core/config/AsyncConfig.java index 14dc801..ea0a388 100644 --- a/ruoyi-common/ruoyi-common-core/src/main/java/com/ruoyi/common/core/config/AsyncConfig.java +++ b/ruoyi-common/ruoyi-common-core/src/main/java/com/ruoyi/common/core/config/AsyncConfig.java @@ -5,6 +5,7 @@ import com.ruoyi.common.core.exception.ServiceException; import com.ruoyi.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.scheduling.annotation.AsyncConfigurer; import org.springframework.scheduling.annotation.EnableAsync; @@ -16,7 +17,7 @@ import java.util.concurrent.Executor; * * @author Lion Li */ -@EnableAsync(proxyTargetClass = true) +@ConditionalOnProperty(prefix = "spring.threads.virtual", name = "enabled", havingValue = "false") @AutoConfiguration public class AsyncConfig implements AsyncConfigurer { diff --git a/ruoyi-common/ruoyi-common-core/src/main/java/com/ruoyi/common/core/config/ThreadPoolConfig.java b/ruoyi-common/ruoyi-common-core/src/main/java/com/ruoyi/common/core/config/ThreadPoolConfig.java index 727ad67..033f67b 100644 --- a/ruoyi-common/ruoyi-common-core/src/main/java/com/ruoyi/common/core/config/ThreadPoolConfig.java +++ b/ruoyi-common/ruoyi-common-core/src/main/java/com/ruoyi/common/core/config/ThreadPoolConfig.java @@ -1,15 +1,11 @@ package com.ruoyi.common.core.config; -import com.ruoyi.common.core.config.properties.ThreadPoolProperties; import com.ruoyi.common.core.utils.Threads; import jakarta.annotation.PreDestroy; import lombok.extern.slf4j.Slf4j; import org.apache.commons.lang3.concurrent.BasicThreadFactory; import org.springframework.boot.autoconfigure.AutoConfiguration; -import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty; -import org.springframework.boot.context.properties.EnableConfigurationProperties; import org.springframework.context.annotation.Bean; -import org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor; import java.util.concurrent.ScheduledExecutorService; import java.util.concurrent.ScheduledThreadPoolExecutor; import java.util.concurrent.ThreadPoolExecutor; @@ -21,7 +17,6 @@ import java.util.concurrent.ThreadPoolExecutor; **/ @Slf4j @AutoConfiguration -@EnableConfigurationProperties(ThreadPoolProperties.class) public class ThreadPoolConfig { /** @@ -31,18 +26,6 @@ public class ThreadPoolConfig private ScheduledExecutorService scheduledExecutorService; - @Bean(name = "threadPoolTaskExecutor") - @ConditionalOnProperty(prefix = "thread-pool", name = "enabled", havingValue = "true") - public ThreadPoolTaskExecutor threadPoolTaskExecutor(ThreadPoolProperties threadPoolProperties) { - ThreadPoolTaskExecutor executor = new ThreadPoolTaskExecutor(); - executor.setCorePoolSize(core); - executor.setMaxPoolSize(core * 2); - executor.setQueueCapacity(threadPoolProperties.getQueueCapacity()); - executor.setKeepAliveSeconds(threadPoolProperties.getKeepAliveSeconds()); - executor.setRejectedExecutionHandler(new ThreadPoolExecutor.CallerRunsPolicy()); - return executor; - } - /** * 执行周期性或定时任务 */ diff --git a/ruoyi-common/ruoyi-common-core/src/main/java/com/ruoyi/common/core/config/properties/ThreadPoolProperties.java b/ruoyi-common/ruoyi-common-core/src/main/java/com/ruoyi/common/core/config/properties/ThreadPoolProperties.java deleted file mode 100644 index d7f4678..0000000 --- a/ruoyi-common/ruoyi-common-core/src/main/java/com/ruoyi/common/core/config/properties/ThreadPoolProperties.java +++ /dev/null @@ -1,30 +0,0 @@ -package com.ruoyi.common.core.config.properties; - -import lombok.Data; -import org.springframework.boot.context.properties.ConfigurationProperties; - -/** - * 线程池 配置属性 - * - * @author Lion Li - */ -@Data -@ConfigurationProperties(prefix = "thread-pool") -public class ThreadPoolProperties { - - /** - * 是否开启线程池 - */ - private boolean enabled; - - /** - * 队列最大长度 - */ - private int queueCapacity; - - /** - * 线程池维护线程所允许的空闲时间 - */ - private int keepAliveSeconds; - -}