chore: 修改uid初始化方式 (#31957)
* chore: 修改uid初始化方式 --------- Co-authored-by: CaptainB <bin@fit2cloud.com>
This commit is contained in:
parent
4ed3cf4ee2
commit
106156a51f
|
@ -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);
|
||||
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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();
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue