From 413b02ddfb392505c1d954b144718dc2455b15a6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=B0=8F=E8=9F=91=E8=9E=82?= Date: Mon, 6 Jul 2026 20:04:32 +0800 Subject: [PATCH] =?UTF-8?q?feat(=E5=90=8E=E7=AB=AF):=20=E6=8B=86=E5=88=86?= =?UTF-8?q?=E9=85=8D=E7=BD=AE=E6=96=87=E4=BB=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../src/main/resources/application-dev.yml | 48 +++++++++++ .../src/main/resources/application-prod.yml | 46 +++++++++++ .../main/resources/application-staging.yml | 45 ++++++++++ .../src/main/resources/application-test.yml | 45 ++++++++++ .../src/main/resources/application.yml | 82 +++++-------------- 5 files changed, 206 insertions(+), 60 deletions(-) create mode 100644 ecom-dmb-backend/src/main/resources/application-dev.yml create mode 100644 ecom-dmb-backend/src/main/resources/application-prod.yml create mode 100644 ecom-dmb-backend/src/main/resources/application-staging.yml create mode 100644 ecom-dmb-backend/src/main/resources/application-test.yml diff --git a/ecom-dmb-backend/src/main/resources/application-dev.yml b/ecom-dmb-backend/src/main/resources/application-dev.yml new file mode 100644 index 00000000..de22cc2a --- /dev/null +++ b/ecom-dmb-backend/src/main/resources/application-dev.yml @@ -0,0 +1,48 @@ +# 开发环境(本地默认 profile) + +spring: + datasource: + url: jdbc:mysql://192.168.3.100:3306/ecom_dmb_dev?characterEncoding=utf-8&serverTimezone=Asia/Shanghai&allowPublicKeyRetrieval=true&nullCatalogMeansCurrent=true + username: ecom_dmb_dev + password: ecom_dmb_dev + data: + redis: + host: 192.168.3.100 + port: 6379 + password: redis_qinghua + database: 2 + +jwt: + secret: your-secret-key-here-must-be-at-least-64-bytes-long-for-hs512-algorithm-security + +mybatis-plus: + configuration: + # 开发环境可按需打开 SQL 日志 + # log-impl: org.apache.ibatis.logging.stdout.StdOutImpl + +order-stat: + nightly-rebuild-enabled: false + +knife4j: + enable: true + +oss: + enabled: false + access-key-id: LTAI5t8oyyor6wLrQasDUQA3 + access-key-secret: U0d3BeKADTJUteSsT5gBtxzlbHoJFi + domain: https://xyquan.oss-cn-guangzhou.aliyuncs.com + +file: + access-domain: http://localhost:5666 + +ecom: + license: + license-key: "" + online-revocation-check: false + license-server-url: "" + +logging: + level: + top.xyquan.ecomdmbbackend: DEBUG + org.springframework.security: INFO + org.springframework.web: INFO diff --git a/ecom-dmb-backend/src/main/resources/application-prod.yml b/ecom-dmb-backend/src/main/resources/application-prod.yml new file mode 100644 index 00000000..308d4f08 --- /dev/null +++ b/ecom-dmb-backend/src/main/resources/application-prod.yml @@ -0,0 +1,46 @@ +# 生产环境 + +spring: + datasource: + url: jdbc:mysql://192.168.3.100:3306/ecom_dmb?characterEncoding=utf-8&serverTimezone=Asia/Shanghai&allowPublicKeyRetrieval=true&nullCatalogMeansCurrent=true + username: ecom_dmb + password: ecom_dmb + hikari: + maximum-pool-size: 20 + minimum-idle: 10 + data: + redis: + host: 192.168.3.100 + port: 6379 + password: redis_qinghua + database: 0 + +jwt: + secret: prod-jwt-secret-key-must-be-at-least-64-bytes-long-for-hs512-algorithm-security + +order-stat: + nightly-rebuild-enabled: true + +knife4j: + enable: false + +oss: + enabled: true + access-key-id: LTAI5t8oyyor6wLrQasDUQA3 + access-key-secret: U0d3BeKADTJUteSsT5gBtxzlbHoJFi + domain: https://xyquan.oss-cn-guangzhou.aliyuncs.com + +file: + access-domain: https://api.example.com + +ecom: + license: + license-key: "" + online-revocation-check: true + license-server-url: "" + +logging: + level: + top.xyquan.ecomdmbbackend: INFO + org.springframework.security: WARN + org.springframework.web: WARN diff --git a/ecom-dmb-backend/src/main/resources/application-staging.yml b/ecom-dmb-backend/src/main/resources/application-staging.yml new file mode 100644 index 00000000..0a092340 --- /dev/null +++ b/ecom-dmb-backend/src/main/resources/application-staging.yml @@ -0,0 +1,45 @@ +# 预发布环境(与生产配置接近,用于上线前验证) + +spring: + datasource: + url: jdbc:mysql://192.168.3.100:3306/ecom_dmb_staging?characterEncoding=utf-8&serverTimezone=Asia/Shanghai&allowPublicKeyRetrieval=true&nullCatalogMeansCurrent=true + username: ecom_dmb_staging + password: ecom_dmb_staging + hikari: + maximum-pool-size: 20 + data: + redis: + host: 192.168.3.100 + port: 6379 + password: redis_qinghua + database: 0 + +jwt: + secret: staging-jwt-secret-key-must-be-at-least-64-bytes-long-for-hs512-algorithm + +order-stat: + nightly-rebuild-enabled: true + +knife4j: + enable: true + +oss: + enabled: true + access-key-id: LTAI5t8oyyor6wLrQasDUQA3 + access-key-secret: U0d3BeKADTJUteSsT5gBtxzlbHoJFi + domain: https://xyquan.oss-cn-guangzhou.aliyuncs.com + +file: + access-domain: https://staging.example.com + +ecom: + license: + license-key: "" + online-revocation-check: true + license-server-url: "" + +logging: + level: + top.xyquan.ecomdmbbackend: INFO + org.springframework.security: INFO + org.springframework.web: INFO diff --git a/ecom-dmb-backend/src/main/resources/application-test.yml b/ecom-dmb-backend/src/main/resources/application-test.yml new file mode 100644 index 00000000..dad41ca7 --- /dev/null +++ b/ecom-dmb-backend/src/main/resources/application-test.yml @@ -0,0 +1,45 @@ +# 测试环境(CI / 集成测试) + +spring: + datasource: + url: jdbc:mysql://192.168.3.100:3306/ecom_dmb_test?characterEncoding=utf-8&serverTimezone=Asia/Shanghai&allowPublicKeyRetrieval=true&nullCatalogMeansCurrent=true + username: ecom_dmb_test + password: ecom_dmb_test + data: + redis: + host: 192.168.3.100 + port: 6379 + password: redis_qinghua + database: 3 + +jwt: + secret: test-jwt-secret-key-must-be-at-least-64-bytes-long-for-hs512-algorithm + +order-stat: + nightly-rebuild-enabled: false + refresh-worker: + enabled: false + +knife4j: + enable: true + +oss: + enabled: false + access-key-id: LTAI5t8oyyor6wLrQasDUQA3 + access-key-secret: U0d3BeKADTJUteSsT5gBtxzlbHoJFi + domain: https://xyquan.oss-cn-guangzhou.aliyuncs.com + +file: + access-domain: http://localhost:5666 + +ecom: + license: + license-key: "" + online-revocation-check: false + license-server-url: "" + +logging: + level: + top.xyquan.ecomdmbbackend: INFO + org.springframework.security: WARN + org.springframework.web: WARN diff --git a/ecom-dmb-backend/src/main/resources/application.yml b/ecom-dmb-backend/src/main/resources/application.yml index e927fa7e..d9108a1d 100644 --- a/ecom-dmb-backend/src/main/resources/application.yml +++ b/ecom-dmb-backend/src/main/resources/application.yml @@ -1,17 +1,12 @@ +# 公共配置;环境差异见 application-{profile}.yml +# 激活方式:--spring.profiles.active=dev|test|staging|prod + server: port: 8080 spring: - datasource: - url: ${DB_URL:jdbc:mysql://192.168.3.100:3306/ecom_dmb_dev?characterEncoding=utf-8&serverTimezone=Asia/Shanghai&allowPublicKeyRetrieval=true&nullCatalogMeansCurrent=true} - username: ${DB_USERNAME:ecom_dmb_dev} - password: ${DB_PASSWORD:ecom_dmb_dev} - hikari: - maximum-pool-size: 10 - minimum-idle: 5 - connection-timeout: 30000 - idle-timeout: 600000 - max-lifetime: 30000 + profiles: + active: dev jackson: time-zone: Asia/Shanghai # 配置404错误处理 - 注释掉,避免影响Swagger文档访问 @@ -20,19 +15,20 @@ spring: web: resources: add-mappings: true - # 文件上传配置 servlet: multipart: max-file-size: 50MB max-request-size: 100MB enabled: true - # Redis配置 + datasource: + hikari: + maximum-pool-size: 10 + minimum-idle: 5 + connection-timeout: 30000 + idle-timeout: 600000 + max-lifetime: 30000 data: redis: - host: ${REDIS_HOST:192.168.3.100} - port: ${REDIS_PORT:6379} - password: ${REDIS_PASSWORD:redis_qinghua} - database: 2 timeout: 10000ms # Lettuce 命令执行超时,需 >= leftPop 的 5 秒等待时间 lettuce: pool: @@ -53,36 +49,26 @@ order-stat: enabled: true ttl-history-seconds: 86400 ttl-today-seconds: 900 - nightly-rebuild-enabled: false nightly-rebuild-cron: "0 30 2 * * ?" -# JWT配置 -# ⚠️ 生产环境必须通过环境变量 JWT_SECRET 覆盖,默认值仅用于本地开发 +# JWT 令牌有效期(密钥见各环境配置) jwt: - secret: ${JWT_SECRET:your-secret-key-here-must-be-at-least-64-bytes-long-for-hs512-algorithm-security} - # 访问令牌有效期:15分钟(900秒) access-token-expiration: 900 - # 刷新令牌有效期:7天(604800秒) refresh-token-expiration: 604800 -# mybatis-plus配置 +# mybatis-plus 配置 mybatis-plus: - # mapper xml文件位置 mapper-locations: classpath:mapper/**/*.xml configuration: - # 驼峰命名转换 map-underscore-to-camel-case: true - # 打印SQL日志(已关闭) - # log-impl: org.apache.ibatis.logging.stdout.StdOutImpl -# knife4j配置 +# OpenAPI / Knife4j springdoc: swagger-ui: path: /swagger-ui.html api-docs: path: /v3/api-docs packages-to-scan: top.xyquan.ecomdmbbackend.modules - # 按模块分组配置 group-configs: - group: "系统模块" paths-to-match: @@ -113,44 +99,20 @@ springdoc: - "/media/file/**" packages-to-scan: "top.xyquan.ecomdmbbackend.modules.media.controller" -# knife4j的增强配置 knife4j: - enable: true - # 开启分组功能 enable-group: true - # 开启搜索功能 enable-search: true - # 开启footer功能 enable-footer: false - # 开启footer自定义 enable-footer-custom: false -# OSS配置 +# OSS(开关与凭证见各环境配置) oss: - enabled: false - endpoint: ${OSS_ENDPOINT:https://oss-cn-guangzhou.aliyuncs.com} - access-key-id: ${OSS_ACCESS_KEY_ID:LTAI5t8oyyor6wLrQasDUQA3} - access-key-secret: ${OSS_ACCESS_KEY_SECRET:U0d3BeKADTJUteSsT5gBtxzlbHoJFi} - bucket-name: ${OSS_BUCKET:xyquan} - domain: ${OSS_DOMAIN:https://xyquan.oss-cn-guangzhou.aliyuncs.com} + endpoint: https://oss-cn-guangzhou.aliyuncs.com + bucket-name: xyquan -# 文件访问配置 -file: - access-domain: http://localhost:5666 # 本地文件访问域名 - -# License 授权配置(开关与公钥见 LicenseEnforcement 源码硬编码) +# License 授权(开关与公钥见 LicenseEnforcement 源码硬编码) ecom: license: - license-key: ${ECOM_LICENSE_KEY:} - license-file: ${ECOM_LICENSE_FILE:config/license.key} - revocation-file: ${ECOM_LICENSE_REVOCATION_FILE:config/revoked.jti} - revalidate-interval: ${ECOM_LICENSE_REVALIDATE_INTERVAL:10} - online-revocation-check: ${ECOM_LICENSE_ONLINE_REVOKE:false} - license-server-url: ${ECOM_LICENSE_SERVER_URL:} - -# 日志配置 -logging: - level: - top.xyquan.ecomdmbbackend: INFO - org.springframework.security: INFO - org.springframework.web: INFO + license-file: config/license.key + revocation-file: config/revoked.jti + revalidate-interval: 10