diff --git a/.mvn/repository/com/fundplatform/fund-common/0.0.1-SNAPSHOT/_remote.repositories b/.mvn/repository/com/fundplatform/fund-common/0.0.1-SNAPSHOT/_remote.repositories index de933e1..dd4d899 100644 --- a/.mvn/repository/com/fundplatform/fund-common/0.0.1-SNAPSHOT/_remote.repositories +++ b/.mvn/repository/com/fundplatform/fund-common/0.0.1-SNAPSHOT/_remote.repositories @@ -1,4 +1,4 @@ #NOTE: This is a Maven Resolver internal implementation file, its format can be changed without prior notice. -#Fri Feb 20 18:12:34 CST 2026 +#Fri Feb 20 18:33:58 CST 2026 fund-common-0.0.1-SNAPSHOT.jar>= fund-common-0.0.1-SNAPSHOT.pom>= diff --git a/.mvn/repository/com/fundplatform/fund-common/0.0.1-SNAPSHOT/fund-common-0.0.1-SNAPSHOT.jar b/.mvn/repository/com/fundplatform/fund-common/0.0.1-SNAPSHOT/fund-common-0.0.1-SNAPSHOT.jar index 6b9b9f2..1b1f8a1 100644 Binary files a/.mvn/repository/com/fundplatform/fund-common/0.0.1-SNAPSHOT/fund-common-0.0.1-SNAPSHOT.jar and b/.mvn/repository/com/fundplatform/fund-common/0.0.1-SNAPSHOT/fund-common-0.0.1-SNAPSHOT.jar differ diff --git a/.mvn/repository/com/fundplatform/fund-common/0.0.1-SNAPSHOT/maven-metadata-local.xml b/.mvn/repository/com/fundplatform/fund-common/0.0.1-SNAPSHOT/maven-metadata-local.xml index 18cd308..a18c0a0 100644 --- a/.mvn/repository/com/fundplatform/fund-common/0.0.1-SNAPSHOT/maven-metadata-local.xml +++ b/.mvn/repository/com/fundplatform/fund-common/0.0.1-SNAPSHOT/maven-metadata-local.xml @@ -3,7 +3,7 @@ com.fundplatform fund-common - 20260220101230 + 20260220103348 true @@ -11,12 +11,12 @@ pom 0.0.1-SNAPSHOT - 20260220101230 + 20260220103348 jar 0.0.1-SNAPSHOT - 20260220101230 + 20260220103348 diff --git a/.mvn/repository/com/fundplatform/fund-common/maven-metadata-local.xml b/.mvn/repository/com/fundplatform/fund-common/maven-metadata-local.xml index 381394d..bcf12c1 100644 --- a/.mvn/repository/com/fundplatform/fund-common/maven-metadata-local.xml +++ b/.mvn/repository/com/fundplatform/fund-common/maven-metadata-local.xml @@ -6,6 +6,6 @@ 0.0.1-SNAPSHOT - 20260220101230 + 20260220103348 diff --git a/.mvn/repository/com/fundplatform/fundplatform/0.0.1-SNAPSHOT/_remote.repositories b/.mvn/repository/com/fundplatform/fundplatform/0.0.1-SNAPSHOT/_remote.repositories index 4fa4571..0aa0a3b 100644 --- a/.mvn/repository/com/fundplatform/fundplatform/0.0.1-SNAPSHOT/_remote.repositories +++ b/.mvn/repository/com/fundplatform/fundplatform/0.0.1-SNAPSHOT/_remote.repositories @@ -1,3 +1,3 @@ #NOTE: This is a Maven Resolver internal implementation file, its format can be changed without prior notice. -#Fri Feb 20 18:12:31 CST 2026 +#Fri Feb 20 18:33:50 CST 2026 fundplatform-0.0.1-SNAPSHOT.pom>= diff --git a/.mvn/repository/com/fundplatform/fundplatform/0.0.1-SNAPSHOT/maven-metadata-local.xml b/.mvn/repository/com/fundplatform/fundplatform/0.0.1-SNAPSHOT/maven-metadata-local.xml index c0e275e..2cc0b6d 100644 --- a/.mvn/repository/com/fundplatform/fundplatform/0.0.1-SNAPSHOT/maven-metadata-local.xml +++ b/.mvn/repository/com/fundplatform/fundplatform/0.0.1-SNAPSHOT/maven-metadata-local.xml @@ -3,7 +3,7 @@ com.fundplatform fundplatform - 20260220101230 + 20260220103348 true @@ -11,7 +11,7 @@ pom 0.0.1-SNAPSHOT - 20260220101230 + 20260220103348 diff --git a/.mvn/repository/com/fundplatform/fundplatform/maven-metadata-local.xml b/.mvn/repository/com/fundplatform/fundplatform/maven-metadata-local.xml index 9165a2b..f85cee8 100644 --- a/.mvn/repository/com/fundplatform/fundplatform/maven-metadata-local.xml +++ b/.mvn/repository/com/fundplatform/fundplatform/maven-metadata-local.xml @@ -6,6 +6,6 @@ 0.0.1-SNAPSHOT - 20260220101230 + 20260220103348 diff --git a/.mvn/repository/org/apache/maven/plugins/maven-clean-plugin/3.3.2/m2e-lastUpdated.properties b/.mvn/repository/org/apache/maven/plugins/maven-clean-plugin/3.3.2/m2e-lastUpdated.properties index d0b2e0c..bb03949 100644 --- a/.mvn/repository/org/apache/maven/plugins/maven-clean-plugin/3.3.2/m2e-lastUpdated.properties +++ b/.mvn/repository/org/apache/maven/plugins/maven-clean-plugin/3.3.2/m2e-lastUpdated.properties @@ -1,2 +1,2 @@ -#Fri Feb 20 11:21:39 CST 2026 -central|https\://repo1.maven.org/maven2|null=1771557699084 +#Fri Feb 20 18:40:08 CST 2026 +central|https\://repo1.maven.org/maven2|null=1771584008125 diff --git a/.mvn/repository/org/apache/maven/plugins/maven-compiler-plugin/3.11.0/m2e-lastUpdated.properties b/.mvn/repository/org/apache/maven/plugins/maven-compiler-plugin/3.11.0/m2e-lastUpdated.properties index 663cac8..b3e1a24 100644 --- a/.mvn/repository/org/apache/maven/plugins/maven-compiler-plugin/3.11.0/m2e-lastUpdated.properties +++ b/.mvn/repository/org/apache/maven/plugins/maven-compiler-plugin/3.11.0/m2e-lastUpdated.properties @@ -1,2 +1,2 @@ -#Fri Feb 20 11:21:39 CST 2026 -central|https\://repo1.maven.org/maven2|null=1771557699091 +#Fri Feb 20 18:40:08 CST 2026 +central|https\://repo1.maven.org/maven2|null=1771584008166 diff --git a/.mvn/repository/org/apache/maven/plugins/maven-deploy-plugin/3.1.1/m2e-lastUpdated.properties b/.mvn/repository/org/apache/maven/plugins/maven-deploy-plugin/3.1.1/m2e-lastUpdated.properties index e25c08b..24de30d 100644 --- a/.mvn/repository/org/apache/maven/plugins/maven-deploy-plugin/3.1.1/m2e-lastUpdated.properties +++ b/.mvn/repository/org/apache/maven/plugins/maven-deploy-plugin/3.1.1/m2e-lastUpdated.properties @@ -1,2 +1,2 @@ -#Fri Feb 20 11:21:39 CST 2026 -central|https\://repo1.maven.org/maven2|null=1771557699097 +#Fri Feb 20 18:40:08 CST 2026 +central|https\://repo1.maven.org/maven2|null=1771584008178 diff --git a/.mvn/repository/org/apache/maven/plugins/maven-install-plugin/3.1.1/m2e-lastUpdated.properties b/.mvn/repository/org/apache/maven/plugins/maven-install-plugin/3.1.1/m2e-lastUpdated.properties index 461661b..a8ce277 100644 --- a/.mvn/repository/org/apache/maven/plugins/maven-install-plugin/3.1.1/m2e-lastUpdated.properties +++ b/.mvn/repository/org/apache/maven/plugins/maven-install-plugin/3.1.1/m2e-lastUpdated.properties @@ -1,2 +1,2 @@ -#Fri Feb 20 11:21:39 CST 2026 -central|https\://repo1.maven.org/maven2|null=1771557699096 +#Fri Feb 20 18:40:08 CST 2026 +central|https\://repo1.maven.org/maven2|null=1771584008176 diff --git a/.mvn/repository/org/apache/maven/plugins/maven-jar-plugin/3.3.0/m2e-lastUpdated.properties b/.mvn/repository/org/apache/maven/plugins/maven-jar-plugin/3.3.0/m2e-lastUpdated.properties index 6800127..4c04b50 100644 --- a/.mvn/repository/org/apache/maven/plugins/maven-jar-plugin/3.3.0/m2e-lastUpdated.properties +++ b/.mvn/repository/org/apache/maven/plugins/maven-jar-plugin/3.3.0/m2e-lastUpdated.properties @@ -1,2 +1,2 @@ -#Fri Feb 20 11:21:39 CST 2026 -central|https\://repo1.maven.org/maven2|null=1771557699093 +#Fri Feb 20 18:40:08 CST 2026 +central|https\://repo1.maven.org/maven2|null=1771584008171 diff --git a/.mvn/repository/org/apache/maven/plugins/maven-resources-plugin/3.3.1/m2e-lastUpdated.properties b/.mvn/repository/org/apache/maven/plugins/maven-resources-plugin/3.3.1/m2e-lastUpdated.properties index f42d137..b7fc38a 100644 --- a/.mvn/repository/org/apache/maven/plugins/maven-resources-plugin/3.3.1/m2e-lastUpdated.properties +++ b/.mvn/repository/org/apache/maven/plugins/maven-resources-plugin/3.3.1/m2e-lastUpdated.properties @@ -1,2 +1,2 @@ -#Fri Feb 20 11:21:39 CST 2026 -central|https\://repo1.maven.org/maven2|null=1771557699090 +#Fri Feb 20 18:40:08 CST 2026 +central|https\://repo1.maven.org/maven2|null=1771584008165 diff --git a/.mvn/repository/org/apache/maven/plugins/maven-site-plugin/3.12.1/m2e-lastUpdated.properties b/.mvn/repository/org/apache/maven/plugins/maven-site-plugin/3.12.1/m2e-lastUpdated.properties index 66d35d6..49a069b 100644 --- a/.mvn/repository/org/apache/maven/plugins/maven-site-plugin/3.12.1/m2e-lastUpdated.properties +++ b/.mvn/repository/org/apache/maven/plugins/maven-site-plugin/3.12.1/m2e-lastUpdated.properties @@ -1,2 +1,2 @@ -#Fri Feb 20 11:21:39 CST 2026 -central|https\://repo1.maven.org/maven2|null=1771557699098 +#Fri Feb 20 18:40:08 CST 2026 +central|https\://repo1.maven.org/maven2|null=1771584008180 diff --git a/.mvn/repository/org/apache/maven/plugins/maven-surefire-plugin/3.1.2/m2e-lastUpdated.properties b/.mvn/repository/org/apache/maven/plugins/maven-surefire-plugin/3.1.2/m2e-lastUpdated.properties index a004257..93d13c8 100644 --- a/.mvn/repository/org/apache/maven/plugins/maven-surefire-plugin/3.1.2/m2e-lastUpdated.properties +++ b/.mvn/repository/org/apache/maven/plugins/maven-surefire-plugin/3.1.2/m2e-lastUpdated.properties @@ -1,2 +1,2 @@ -#Fri Feb 20 11:21:39 CST 2026 -central|https\://repo1.maven.org/maven2|null=1771557699092 +#Fri Feb 20 18:40:08 CST 2026 +central|https\://repo1.maven.org/maven2|null=1771584008169 diff --git a/.mvn/repository/org/springframework/boot/spring-boot-maven-plugin/3.2.0/m2e-lastUpdated.properties b/.mvn/repository/org/springframework/boot/spring-boot-maven-plugin/3.2.0/m2e-lastUpdated.properties index 911888b..a50a2c4 100644 --- a/.mvn/repository/org/springframework/boot/spring-boot-maven-plugin/3.2.0/m2e-lastUpdated.properties +++ b/.mvn/repository/org/springframework/boot/spring-boot-maven-plugin/3.2.0/m2e-lastUpdated.properties @@ -1,2 +1,2 @@ -#Fri Feb 20 11:21:39 CST 2026 -central|https\://repo1.maven.org/maven2|null=1771557699094 +#Fri Feb 20 18:40:08 CST 2026 +central|https\://repo1.maven.org/maven2|null=1771584008173 diff --git a/fund-common/src/main/java/com/fundplatform/common/loadbalancer/TenantAwareLoadBalancer.java b/fund-common/src/main/java/com/fundplatform/common/loadbalancer/TenantAwareLoadBalancer.java index 646aabb..e58d612 100644 --- a/fund-common/src/main/java/com/fundplatform/common/loadbalancer/TenantAwareLoadBalancer.java +++ b/fund-common/src/main/java/com/fundplatform/common/loadbalancer/TenantAwareLoadBalancer.java @@ -62,6 +62,12 @@ public class TenantAwareLoadBalancer implements ReactorServiceInstanceLoadBalanc @Override public Mono> choose(Request request) { + // 如果 serviceId 为 null,直接返回空响应 + if (serviceId == null || serviceId.isEmpty()) { + logger.warn("[TenantLB] serviceId 为空,无法进行负载均衡"); + return Mono.just(new EmptyResponse()); + } + // 检查是否启用租户路由 if (routingProperties != null && !routingProperties.isEnabled()) { logger.debug("[TenantLB] 租户路由已禁用,使用默认路由"); diff --git a/fund-common/src/main/java/com/fundplatform/common/loadbalancer/TenantLoadBalancerAutoConfig.java b/fund-common/src/main/java/com/fundplatform/common/loadbalancer/TenantLoadBalancerAutoConfig.java index acfb4a6..3bfea35 100644 --- a/fund-common/src/main/java/com/fundplatform/common/loadbalancer/TenantLoadBalancerAutoConfig.java +++ b/fund-common/src/main/java/com/fundplatform/common/loadbalancer/TenantLoadBalancerAutoConfig.java @@ -3,6 +3,7 @@ package com.fundplatform.common.loadbalancer; import com.fundplatform.common.config.TenantRoutingProperties; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty; +import org.springframework.cloud.loadbalancer.annotation.LoadBalancerClients; import org.springframework.cloud.loadbalancer.core.ReactorServiceInstanceLoadBalancer; import org.springframework.cloud.loadbalancer.core.ServiceInstanceListSupplier; import org.springframework.cloud.loadbalancer.support.LoadBalancerClientFactory; @@ -30,10 +31,23 @@ import org.springframework.core.env.Environment; */ @Configuration @ConditionalOnProperty(name = "tenant.routing.enabled", havingValue = "true", matchIfMissing = true) +@LoadBalancerClients(defaultConfiguration = TenantLoadBalancerConfig.class) public class TenantLoadBalancerAutoConfig { @Autowired(required = false) private TenantRoutingProperties routingProperties; +} + +/** + * 租户感知负载均衡器配置类 + * + *

为每个服务创建租户感知的负载均衡器实例

+ */ +@Configuration +class TenantLoadBalancerConfig { + + @Autowired(required = false) + private TenantRoutingProperties routingProperties; /** * 注册租户感知负载均衡器 diff --git a/fund-gateway/pom.xml b/fund-gateway/pom.xml index 74bbdca..1044488 100644 --- a/fund-gateway/pom.xml +++ b/fund-gateway/pom.xml @@ -35,6 +35,12 @@ 4.0.0 + + + com.alibaba.cloud + spring-cloud-starter-alibaba-nacos-discovery + + org.springframework.boot diff --git a/fund-gateway/src/main/resources/application.yml b/fund-gateway/src/main/resources/application.yml index 93d95da..633bb6f 100644 --- a/fund-gateway/src/main/resources/application.yml +++ b/fund-gateway/src/main/resources/application.yml @@ -71,7 +71,8 @@ spring: - id: fund-cust uri: lb://fund-cust predicates: - - Path=/cust/** + - Path=/cust/**Default Namespace + filters: - StripPrefix=1 @@ -128,16 +129,7 @@ logging: org.springframework.cloud.gateway: DEBUG com.fundplatform.common.loadbalancer: DEBUG -# 多租户路由配置(Gateway 全局配置) +# 多租户路由配置 tenant: routing: enabled: true - tenant-header: X-Tenant-Id - default-tenant-id: "1" - # 共享服务列表(不需要租户路由的服务) - shared-services: - - fund-gateway - - fund-report - - fund-file - # 默认回退策略 - fallback-to-shared: true