From 641348c59be38259b9e9f2b58e3b055f8e9d72b7 Mon Sep 17 00:00:00 2001 From: gaoqr <13665037151@163.com> Date: Thu, 17 Jul 2025 12:08:42 +0800 Subject: [PATCH] =?UTF-8?q?error-code=E5=86=99=E5=85=A5=E6=97=B6=E6=9C=BA?= =?UTF-8?q?=E8=B0=83=E6=95=B4=E6=B5=8B=E8=AF=95=E8=BF=98=E5=8E=9F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../generator/ErrorCodeAutoGeneratorImpl.java | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-) diff --git a/cf-framework/cf-spring-boot-starter-web/src/main/java/com/cf/imes/framework/errorcode/core/generator/ErrorCodeAutoGeneratorImpl.java b/cf-framework/cf-spring-boot-starter-web/src/main/java/com/cf/imes/framework/errorcode/core/generator/ErrorCodeAutoGeneratorImpl.java index 23a64ad3d..f408dadbe 100644 --- a/cf-framework/cf-spring-boot-starter-web/src/main/java/com/cf/imes/framework/errorcode/core/generator/ErrorCodeAutoGeneratorImpl.java +++ b/cf-framework/cf-spring-boot-starter-web/src/main/java/com/cf/imes/framework/errorcode/core/generator/ErrorCodeAutoGeneratorImpl.java @@ -9,8 +9,8 @@ import com.cf.imes.module.system.api.errorcode.ErrorCodeApi; import com.cf.imes.module.system.api.errorcode.dto.ErrorCodeAutoGenerateReqDTO; import lombok.RequiredArgsConstructor; import lombok.extern.slf4j.Slf4j; -import org.springframework.boot.web.context.WebServerInitializedEvent; -import org.springframework.context.ApplicationListener; +import org.springframework.boot.context.event.ApplicationReadyEvent; +import org.springframework.context.event.EventListener; import org.springframework.scheduling.annotation.Async; import java.util.ArrayList; @@ -25,7 +25,8 @@ import java.util.List; */ @RequiredArgsConstructor @Slf4j -public class ErrorCodeAutoGeneratorImpl implements ErrorCodeAutoGenerator, ApplicationListener { +public class ErrorCodeAutoGeneratorImpl implements ErrorCodeAutoGenerator { + /** * 应用分组 */ @@ -40,8 +41,9 @@ public class ErrorCodeAutoGeneratorImpl implements ErrorCodeAutoGenerator, Appli private final ErrorCodeApi errorCodeApi; @Override - @Async - public void onApplicationEvent(WebServerInitializedEvent event) { + @EventListener(ApplicationReadyEvent.class) + @Async // 异步,保证项目的启动过程,毕竟非关键流程 + public void execute() { // 第一步,解析错误码 List autoGenerateDTOs = parseErrorCode(); log.info("[execute][解析到错误码数量为 ({}) 个]", autoGenerateDTOs.size()); @@ -102,8 +104,4 @@ public class ErrorCodeAutoGeneratorImpl implements ErrorCodeAutoGenerator, Appli return autoGenerateDTOs; } - @Override - public void execute() { - - } }