跳转到内容

配置项参考

codingas.com 通过 application.yml 与环境变量配置。所有可变参数均支持环境变量注入(${VAR:default} 语法)。配置文件位于 gateway-boot/src/main/resources/

配置项环境变量默认值说明
server.portSERVER_PORT8080服务端口
server.addressSERVER_ADDRESS0.0.0.0绑定地址
spring.profiles.activeSPRING_PROFILES_ACTIVElocal激活的 profile
配置项环境变量默认值说明
spring.datasource.urlDB_URLH2 文件JDBC URL
spring.datasource.driver-class-nameDB_DRIVERorg.h2.Driver驱动类
spring.datasource.usernameDB_USERNAMEsa数据库用户
spring.datasource.passwordDB_PASSWORD数据库密码
spring.datasource.hikari.maximum-pool-sizeHIKARI_MAX_POOL_SIZE10连接池上限
spring.datasource.hikari.minimum-idleHIKARI_MIN_IDLE5最小空闲连接

PostgreSQL 模式示例:

spring:
datasource:
url: jdbc:postgresql://localhost:5432/llm_gateway
driver-class-name: org.postgresql.Driver
username: ${DB_USERNAME}
password: ${DB_PASSWORD}

默认关闭(local/dev profile),postgresql/prod profile 启用。

配置项环境变量默认值说明
spring.data.redis.enabled-false是否启用 Redis
spring.data.redis.hostREDIS_HOSTlocalhostRedis 主机
spring.data.redis.portREDIS_PORT6379Redis 端口
spring.data.redis.passwordREDIS_PASSWORDRedis 密码
配置项环境变量默认值说明
gateway.security.encryption-keyENCRYPTION_KEYAPI Key 加密密钥(Base64 32 字节,生产必填)

生成密钥:

Terminal window
openssl rand -base64 32

密钥获取顺序:配置属性 → 环境变量 ENCRYPTION_KEY → 开发环境临时密钥。GATEWAY_ENCRYPTION_KEY 仅在 local profile 的 yml 映射中生效。非开发 profile 未配置时启动抛 ENCRYPTION_KEY_MISSING。密钥丢失将导致已加密的上游 Key 无法解密。

配置项默认值说明
gateway.security.rate-limit.bucket-size100令牌桶容量
gateway.security.rate-limit.refill-rate10每秒补充令牌数
gateway.security.rate-limit.qps-threshold1000QPS 阈值
配置项默认值说明
gateway.retry.max-attempts3默认最大重试次数
gateway.retry.backoff-initial1000(ms)退避起始间隔
gateway.retry.backoff-multiplier2.0退避倍率
gateway.retry.retryable-status-codes429,500,502,503可重试状态码
gateway.retry.rate-limit.*5 次 / 2000ms 起 / 60s 封顶上游限流专用策略
gateway.retry.fast-retry.*2 次 / 固定 500ms超时快速重试策略
gateway.retry.service-unavailable.*3 次 / 固定 5000ms服务不可用策略
配置项默认值说明
webclient.connect-timeout5000(ms)连接超时
webclient.read-timeout60000(ms)读取超时
配置项默认值说明
gateway.init.demo-data-enabledfalselocal/devtrue是否加载示例数据
gateway.actuator.health.public-accesstrue健康检查公网可访问
gateway.protocol.gemini.enabledtrueGemini 协议插件(上游适配扩展示例)
gateway.health.provider.stale-threshold300sProvider 健康状态过期阈值
gateway.health.provider.failure-threshold3连续失败熔断阈值
gateway.health.provider.success-threshold2连续成功恢复阈值
gateway.health.provider.probe-timeout10s健康探测超时
spring.jpa.ddl-autoupdatepostgresql profile 为 validateSchema 同步策略
配置项默认值说明
sa-token.token-nameAuthorizationToken 头名称
sa-token.token-prefixBearerToken 前缀
sa-token.timeout7200会话超时(秒)
sa-token.is-read-headertrue从 Header 读取 Token
端点说明
/actuator/health健康检查
/actuator/health/liveness存活探针
/actuator/health/readiness就绪探针
/actuator/prometheusPrometheus 指标
/actuator/info应用信息
Profile数据库Redis用途
local(默认)H2 文件关闭本地开发,预置示例数据
devH2 文件关闭开发调试
postgresqlPostgreSQL启用生产推荐
standalone同上Caffeine单机
prod同上启用生产

完整占位符清单见 gateway-boot/src/main/resources/application.yml${ENV:默认值} 定义。部署细节见 安装部署