diff --git a/backend/app/src/main/java/io/metersphere/listener/AppStartListener.java b/backend/app/src/main/java/io/metersphere/listener/AppStartListener.java index f59a8f7035..a31b4cdc16 100644 --- a/backend/app/src/main/java/io/metersphere/listener/AppStartListener.java +++ b/backend/app/src/main/java/io/metersphere/listener/AppStartListener.java @@ -33,7 +33,7 @@ public class AppStartListener implements ApplicationRunner { @Override public void run(ApplicationArguments args) throws Exception { LogUtils.info("================= 应用启动 ================="); - defaultUidGenerator.afterPropertiesSet(); + defaultUidGenerator.init(); // 初始化MinIO配置 ((MinioRepository) FileCenter.getRepository(StorageType.MINIO)).init(minioClient); diff --git a/backend/services/system-setting/src/main/java/io/metersphere/system/uid/impl/DefaultUidGenerator.java b/backend/services/system-setting/src/main/java/io/metersphere/system/uid/impl/DefaultUidGenerator.java index d5f8b11fa2..833f27c16a 100644 --- a/backend/services/system-setting/src/main/java/io/metersphere/system/uid/impl/DefaultUidGenerator.java +++ b/backend/services/system-setting/src/main/java/io/metersphere/system/uid/impl/DefaultUidGenerator.java @@ -9,14 +9,13 @@ import io.metersphere.sdk.util.LogUtils; import jakarta.annotation.Resource; import org.apache.commons.lang3.StringUtils; import org.springframework.beans.factory.DisposableBean; -import org.springframework.beans.factory.InitializingBean; import org.springframework.stereotype.Service; import java.util.Date; import java.util.concurrent.TimeUnit; @Service -public class DefaultUidGenerator implements DisposableBean, InitializingBean { +public class DefaultUidGenerator implements DisposableBean { /** * Bits allocate */ @@ -48,7 +47,7 @@ public class DefaultUidGenerator implements DisposableBean, InitializingBean { @Resource protected WorkerIdAssigner workerIdAssigner; - public void afterPropertiesSet() { + public void init() { // init bitsAllocator this.setTimeBits(29); this.setWorkerBits(21); diff --git a/backend/services/system-setting/src/test/java/io/metersphere/system/config/AppStartListener.java b/backend/services/system-setting/src/test/java/io/metersphere/system/config/AppStartListener.java new file mode 100644 index 0000000000..b266f1e33b --- /dev/null +++ b/backend/services/system-setting/src/test/java/io/metersphere/system/config/AppStartListener.java @@ -0,0 +1,21 @@ +package io.metersphere.system.config; + +import io.metersphere.sdk.util.LogUtils; +import io.metersphere.system.uid.impl.DefaultUidGenerator; +import jakarta.annotation.Resource; +import org.springframework.boot.ApplicationArguments; +import org.springframework.boot.ApplicationRunner; +import org.springframework.stereotype.Component; + +@Component +public class AppStartListener implements ApplicationRunner { + + @Resource + private DefaultUidGenerator defaultUidGenerator; + + @Override + public void run(ApplicationArguments args) throws Exception { + LogUtils.info("================= 应用启动 ================="); + defaultUidGenerator.init(); + } +}