refactor: read database connection and config from environment variables like mediabot

This commit is contained in:
mediabot-pt
2026-06-29 10:59:02 +08:00
parent 13ce7d95dd
commit 25cd9873ae

View File

@@ -5,16 +5,17 @@ spring:
application: application:
name: par-server name: par-server
datasource: datasource:
url: jdbc:mysql://localhost:3306/par_registry?useUnicode=true&characterEncoding=utf-8&serverTimezone=Asia/Shanghai url: jdbc:mysql://${MYSQL_HOST:localhost}:${MYSQL_PORT:3306}/${MYSQL_DB:par_registry}?useUnicode=true&characterEncoding=utf-8&serverTimezone=Asia/Shanghai&useSSL=false&allowPublicKeyRetrieval=true
username: ${MYSQL_USER:par} username: ${MYSQL_USER:root}
password: ${MYSQL_PASSWORD:par123} password: ${MYSQL_PASSWORD:root}
driver-class-name: com.mysql.cj.jdbc.Driver driver-class-name: com.mysql.cj.jdbc.Driver
hikari: hikari:
maximum-pool-size: 20
minimum-idle: 5 minimum-idle: 5
maximum-pool-size: 20
connection-timeout: 30000 connection-timeout: 30000
idle-timeout: 600000 idle-timeout: 600000
max-lifetime: 1800000 max-lifetime: 1800000
connection-init-sql: SET SESSION lock_wait_timeout=10
jackson: jackson:
date-format: yyyy-MM-dd HH:mm:ss date-format: yyyy-MM-dd HH:mm:ss
@@ -23,7 +24,7 @@ spring:
web: web:
resources: resources:
static-locations: file:${par.static.path:./static/} static-locations: file:${PAR_STATIC_PATH:./static/}
flyway: flyway:
enabled: true enabled: true
@@ -56,6 +57,10 @@ par:
login-max-failures: 5 login-max-failures: 5
login-lock-minutes: 30 login-lock-minutes: 30
# HMAC 签名密钥(生产环境必须配置随机密钥)
hmac:
secret: ${HMAC_SECRET:}
logging: logging:
level: level:
com.par: DEBUG com.par: DEBUG