From ff71aa633c6df74d52efaf7ad02ad82f1f20ca41 Mon Sep 17 00:00:00 2001 From: Agent Date: Fri, 20 Mar 2026 15:13:07 +0000 Subject: [PATCH] Config via environment variables --- src/main/resources/application.yml | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/src/main/resources/application.yml b/src/main/resources/application.yml index ff44e15..78bdc8e 100644 --- a/src/main/resources/application.yml +++ b/src/main/resources/application.yml @@ -5,18 +5,18 @@ spring: application: name: building - # PostgreSQL数据库配置 + # PostgreSQL数据库配置 - 环境变量注入 datasource: driver-class-name: org.postgresql.Driver - url: jdbc:postgresql://localhost:5432/building_materials - username: postgres - password: postgres + url: jdbc:postgresql://${SPRING_DATASOURCE_HOST:localhost}:${SPRING_DATASOURCE_PORT:5432}/${SPRING_DATASOURCE_DB:building_materials} + username: ${SPRING_DATASOURCE_USERNAME:postgres} + password: ${SPRING_DATASOURCE_PASSWORD:postgres} - # Redis配置 + # Redis配置 - 环境变量注入 redis: - host: localhost - port: 6379 - password: + host: ${SPRING_REDIS_HOST:localhost} + port: ${SPRING_REDIS_PORT:6379} + password: ${SPRING_REDIS_PASSWORD:} database: 0 timeout: 3000ms lettuce: @@ -38,11 +38,11 @@ mybatis-plus: logic-delete-value: 0 logic-not-delete-value: 1 -# JWT配置 +# JWT配置 - 环境变量注入 jwt: - secret: building-materials-secret-key-2024 - expiration: 7200000 # 2小时 - refresh-expiration: 604800000 # 7天 + secret: ${JWT_SECRET:building-materials-secret-key-2024} + expiration: ${JWT_EXPIRATION:7200000} + refresh-expiration: ${JWT_REFRESH_EXPIRATION:604800000} # 日志配置 logging: