fundplatform/fund-gateway/target/classes/application-docker.yml
zhangjf 8e4afcd1a5 feat: TenantAwareLoadBalancer 整合 TenantRoutingProperties 配置
问题:TenantRoutingProperties 定义了配置但未被使用

解决方案:
1. TenantAwareLoadBalancer 注入 TenantRoutingProperties
   - 使用配置的 tenantHeader 名称
   - 使用配置的 buildTenantGroup 方法
   - 使用配置的 isSharedService 判断
   - 使用配置的 isFallbackToShared 策略

2. 新增功能
   - 支持 enabled=false 禁用租户路由
   - 共享服务跳过租户过滤
   - 可配置是否回退到共享实例

3. 更新测试适配新构造函数
2026-02-19 21:02:25 +08:00

167 lines
4.1 KiB
YAML
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

# Docker 环境配置 - Gateway
server:
port: ${SERVER_PORT:8000}
spring:
application:
name: fund-gateway
profiles:
active: ${SPRING_PROFILES_ACTIVE:docker}
cloud:
nacos:
server-addr: ${NACOS_SERVER_ADDR:nacos:8848}
username: ${NACOS_USERNAME:nacos}
password: ${NACOS_PASSWORD:nacos}
discovery:
namespace: ${NACOS_NAMESPACE:}
group: DEFAULT_GROUP
enabled: true
metadata:
service-type: gateway
gateway:
discovery:
locator:
enabled: true
lower-case-service-id: true
# 全局跨域配置
globalcors:
cors-configurations:
'[/**]':
allowed-origins: "*"
allowed-methods: "*"
allowed-headers: "*"
allow-credentials: true
routes:
- id: fund-sys
uri: lb://fund-sys
predicates:
- Path=/api/sys/**
filters:
- StripPrefix=1
# 租户感知负载均衡(自动添加 tenant-group 请求头)
- id: fund-cust
uri: lb://fund-cust
predicates:
- Path=/api/cust/**
filters:
- StripPrefix=1
- id: fund-proj
uri: lb://fund-proj
predicates:
- Path=/api/proj/**
filters:
- StripPrefix=1
- id: fund-req
uri: lb://fund-req
predicates:
- Path=/api/req/**
filters:
- StripPrefix=1
- id: fund-exp
uri: lb://fund-exp
predicates:
- Path=/api/exp/**
filters:
- StripPrefix=1
- id: fund-receipt
uri: lb://fund-receipt
predicates:
- Path=/api/receipt/**
filters:
- StripPrefix=1
- id: fund-report
uri: lb://fund-report
predicates:
- Path=/api/report/**
filters:
- StripPrefix=1
- id: fund-file
uri: lb://fund-file
predicates:
- Path=/api/file/**
filters:
- StripPrefix=1
# JWT 配置
jwt:
secret: ${JWT_SECRET:YourSecretKeyForJWTTokenGenerationMustBeAtLeast256BitsLong}
expiration: ${JWT_EXPIRATION:86400000}
# ==================== 多租户混合模式配置 ====================
tenant:
routing:
# 启用租户感知负载均衡
enabled: true
# 默认租户ID
default-tenant-id: 1
# 租户服务配置定义每个服务的VIP租户
services:
fund-sys:
vip-tenants:
- TENANT_VIP_001
- TENANT_VIP_002
fallback-to-shared: true
fund-cust:
vip-tenants:
- TENANT_VIP_001
fallback-to-shared: true
fund-proj:
vip-tenants:
- TENANT_VIP_001
fallback-to-shared: true
fund-req:
vip-tenants: []
fallback-to-shared: true
fund-exp:
vip-tenants: []
fallback-to-shared: true
fund-receipt:
vip-tenants: []
fallback-to-shared: true
fund-report:
vip-tenants: []
fallback-to-shared: true
fund-file:
vip-tenants: []
fallback-to-shared: true
# Actuator 监控端点配置
management:
endpoints:
web:
exposure:
include: health,info,metrics,prometheus
base-path: /actuator
endpoint:
health:
show-details: always
probes:
enabled: true
health:
livenessstate:
enabled: true
readinessstate:
enabled: true
metrics:
tags:
application: ${spring.application.name}
service-type: gateway
distribution:
percentiles-histogram:
http.server.requests: true
percentiles:
http.server.requests: 0.5,0.95,0.99
# 日志配置
logging:
level:
root: INFO
com.fundplatform: DEBUG
# 多租户负载均衡日志
com.fundplatform.common.loadbalancer: DEBUG
com.fundplatform.gateway.filter: DEBUG
pattern:
console: "%d{yyyy-MM-dd HH:mm:ss.SSS} [%thread] [%X{traceId}] [%X{tenantId}] %-5level %logger{36} - %msg%n"