fundplatform/fund-gateway/src/main/resources/application-docker.yml
zhangjf 2c0f2f8952 feat: 服务资源配置文件增加多租户混合模式负载均衡配置
## application-docker.yml 更新

### fund-sys
- Nacos 元数据配置:tenant-id, tenant-group
- 租户路由配置:启用租户感知负载均衡
- VIP 租户列表定义
- 监控标签:tenant_id, tenant_group, instance_type
- 日志格式:增加 tenantId MDC

### fund-gateway
- 全局跨域配置
- 多租户路由配置(所有服务的VIP租户列表)
- 监控和日志增强

## TenantRoutingProperties 更新
- 添加 @ConfigurationProperties 支持 YAML 配置绑定
- 新增 vip-tenants 列表属性
- 新增 fallback-to-shared 回退策略属性
- 新增 getVipTenants(), isVipTenant(), isFallbackToShared() 方法
2026-02-19 20:45:03 +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"