From a902b8fcd946fa6b3fbab08c8c2c84ab2fdafb2f 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, 13 Dec 2023 13:18:06 +0800 Subject: [PATCH] =?UTF-8?q?fix=20=E4=BF=AE=E5=A4=8D=20=E5=8D=87=E7=BA=A7po?= =?UTF-8?q?werjob=E5=AF=BC=E8=87=B4common-job=E6=8F=92=E4=BB=B6=E5=BC=82?= =?UTF-8?q?=E5=B8=B8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../common/job/config/PowerJobConfig.java | 16 +++++++--------- .../config/properties/PowerJobProperties.java | 6 +++--- 2 files changed, 10 insertions(+), 12 deletions(-) diff --git a/ruoyi-common/ruoyi-common-job/src/main/java/org/dromara/common/job/config/PowerJobConfig.java b/ruoyi-common/ruoyi-common-job/src/main/java/org/dromara/common/job/config/PowerJobConfig.java index 75f9412c..35612f3b 100644 --- a/ruoyi-common/ruoyi-common-job/src/main/java/org/dromara/common/job/config/PowerJobConfig.java +++ b/ruoyi-common/ruoyi-common-job/src/main/java/org/dromara/common/job/config/PowerJobConfig.java @@ -1,8 +1,8 @@ package org.dromara.common.job.config; import cn.hutool.core.collection.CollUtil; -import org.apache.commons.lang3.StringUtils; import org.dromara.common.core.utils.StreamUtils; +import org.dromara.common.core.utils.StringUtils; import org.dromara.common.job.config.properties.PowerJobProperties; import org.springframework.boot.autoconfigure.AutoConfiguration; import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty; @@ -10,7 +10,6 @@ import org.springframework.boot.context.properties.EnableConfigurationProperties import org.springframework.cloud.client.ServiceInstance; import org.springframework.cloud.client.discovery.DiscoveryClient; import org.springframework.context.annotation.Bean; -import org.springframework.scheduling.annotation.EnableScheduling; import tech.powerjob.common.utils.CommonUtils; import tech.powerjob.common.utils.NetUtils; import tech.powerjob.worker.PowerJobSpringWorker; @@ -20,16 +19,15 @@ import java.util.Arrays; import java.util.List; /** - * 启动定时任务 + * Autoconfiguration class for PowerJob-worker. * - * @author yhan219 - * @since 2023/6/2 + * @author songyinyin + * @since 2020/7/26 16:37 */ @AutoConfiguration -@ConditionalOnProperty(prefix = "powerjob.worker", name = "enabled", havingValue = "true") @EnableConfigurationProperties(PowerJobProperties.class) -@EnableScheduling -public class PowerJobConfig { +@ConditionalOnProperty(prefix = "powerjob.worker", name = "enabled", havingValue = "true", matchIfMissing = true) +public class PowerJobConfig{ @Bean public PowerJobSpringWorker initPowerJob(PowerJobProperties properties, DiscoveryClient discoveryClient) { @@ -87,7 +85,7 @@ public class PowerJobConfig { * When enabledTestMode is set as true, PowerJob-worker no longer connects to PowerJob-server * or validate appName. */ - config.setEnableTestMode(worker.isEnableTestMode()); + config.setAllowLazyConnectServer(worker.isAllowLazyConnectServer()); /* * Max length of appended workflow context . Appended workflow context value that is longer than the value will be ignored. */ diff --git a/ruoyi-common/ruoyi-common-job/src/main/java/org/dromara/common/job/config/properties/PowerJobProperties.java b/ruoyi-common/ruoyi-common-job/src/main/java/org/dromara/common/job/config/properties/PowerJobProperties.java index 4b7bd7a3..df5f2853 100644 --- a/ruoyi-common/ruoyi-common-job/src/main/java/org/dromara/common/job/config/properties/PowerJobProperties.java +++ b/ruoyi-common/ruoyi-common-job/src/main/java/org/dromara/common/job/config/properties/PowerJobProperties.java @@ -81,10 +81,10 @@ public class PowerJobProperties { */ private int maxResultLength = 8192; /** - * If test mode is set as true, Powerjob-worker no longer connects to the server or validates appName. - * Test mode is used for conditions that your have no powerjob-server in your develop env, so you can't start up the application + * If allowLazyConnectServer is set as true, PowerJob worker allows launching without a direct connection to the server. + * allowLazyConnectServer is used for conditions that your have no powerjob-server in your develop env so you can't startup the application */ - private boolean enableTestMode = false; + private boolean allowLazyConnectServer = false; /** * Max length of appended workflow context value length. Appended workflow context value that is longer than the value will be ignored. * {@link WorkflowContext} max length for #appendedContextData