Browse Source

fix(backend): 以 @Lazy 打破 IndicatorMappingService↔AiGateway 循环依赖,修复应用上下文启动失败

iwt 2 days ago
parent
commit
9581e2d4e5

+ 6 - 1
cfc-backend/src/main/java/com/etotem/cfc/service/IndicatorMappingService.java

@@ -9,6 +9,8 @@ import com.fasterxml.jackson.databind.JsonNode;
 import com.fasterxml.jackson.databind.ObjectMapper;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.context.annotation.Lazy;
 import org.springframework.stereotype.Service;
 
 import javax.annotation.Resource;
@@ -35,7 +37,10 @@ public class IndicatorMappingService {
     @Resource
     private IndicatorDefinitionMapper definitionMapper;
 
-    @Resource
+    // 循环依赖破环:AiGateway→BasicQuotaService→MembershipService→…→HealthReportService→本类。
+    // @Lazy 仅对 @Autowired 生效(非 @Resource);AI 兜底按需触发,懒加载可安全打破 Spring Boot 2.7 默认的循环引用禁令。
+    @Lazy
+    @Autowired
     private AiGateway aiGateway;
 
     @Resource