fix: 修订配置文件路径,移除resources/conf子目录

- 配置文件直接放在 src/main/resources/ 目录下
- 更新 assembly.xml 从 resources 目录获取配置文件
- 更新 .gitignore 忽略路径
- 同步更新架构设计文档和配置规范落地说明
This commit is contained in:
zhangjf 2026-02-24 17:51:41 +08:00
parent ae7fb43e39
commit ae97de3d69
6 changed files with 31 additions and 119 deletions

8
.gitignore vendored
View File

@ -48,11 +48,9 @@ application-test.yml
application-prod.yml
bootstrap.yml
# conf 目录下的实际配置文件(敏感信息)
# 开发阶段src/main/resources/conf/
# 部署阶段conf/(打包后)
src/main/resources/conf/env.properties
src/main/resources/conf/service.properties
# 实际配置文件(敏感信息,仅模板提交)
src/main/resources/env.properties
src/main/resources/service.properties
# 数据库备份
*.sql.backup

View File

@ -958,7 +958,7 @@ worklog-api/
```
**说明**
- 开发阶段:配置文件在 `src/main/resources/conf/` 目录,跟随源码管理
- 开发阶段:配置文件直接`src/main/resources/` 目录,跟随源码管理
- 部署阶段:通过 Maven Assembly 插件打包后,配置文件输出到 `conf/` 目录,位于应用根目录
开发环境配置文件结构:
@ -966,8 +966,13 @@ worklog-api/
```text
src/main/resources/
├── application.yml # 主配置文件Spring Boot 配置)
├── application.yml.example # 主配置模板
├── bootstrap.yml # 启动配置Nacos 配置中心,可选)
└── logback-spring.xml # 日志配置(从环境变量读取参数)
├── logback-spring.xml # 日志配置(从环境变量读取参数)
├── env.properties # 统一环境配置(敏感信息,不提交)
├── env.properties.example # 环境配置模板
├── service.properties # 服务个性化配置(敏感信息,不提交)
└── service.properties.example # 服务配置模板
```
##### 9.4.5.2 配置加载顺序

View File

@ -10,10 +10,10 @@
**新增配置文件**
- [`src/main/resources/conf/env.properties`](file:///home/along/MyCode/wanjiabuluo/worklog/worklog-api/src/main/resources/conf/env.properties) - 统一环境配置(所有服务共用)
- [`src/main/resources/conf/service.properties`](file:///home/along/MyCode/wanjiabuluo/worklog/worklog-api/src/main/resources/conf/service.properties) - 服务个性化配置
- [`src/main/resources/conf/env.properties.example`](file:///home/along/MyCode/wanjiabuluo/worklog/worklog-api/src/main/resources/conf/env.properties.example) - 环境配置模板
- [`src/main/resources/conf/service.properties.example`](file:///home/along/MyCode/wanjiabuluo/worklog/worklog-api/src/main/resources/conf/service.properties.example) - 服务配置模板
- [`src/main/resources/env.properties`](file:///home/along/MyCode/wanjiabuluo/worklog/worklog-api/src/main/resources/env.properties) - 统一环境配置(所有服务共用)
- [`src/main/resources/service.properties`](file:///home/along/MyCode/wanjiabuluo/worklog/worklog-api/src/main/resources/service.properties) - 服务个性化配置
- [`src/main/resources/env.properties.example`](file:///home/along/MyCode/wanjiabuluo/worklog/worklog-api/src/main/resources/env.properties.example) - 环境配置模板
- [`src/main/resources/service.properties.example`](file:///home/along/MyCode/wanjiabuluo/worklog/worklog-api/src/main/resources/service.properties.example) - 服务配置模板
**配置内容说明**
@ -117,9 +117,9 @@
**新增忽略项**
```gitignore
# conf 目录下的实际配置文件(敏感信息)
worklog-api/src/main/resources/conf/env.properties
worklog-api/src/main/resources/conf/service.properties
# 实际配置文件(敏感信息,仅模板提交
src/main/resources/env.properties
src/main/resources/service.properties
```
**安全策略**
@ -153,17 +153,18 @@ worklog-api/src/main/resources/conf/service.properties
```text
worklog-api/src/main/resources/
├── conf/ # 配置文件目录(开发阶段)
│ ├── env.properties # 统一环境配置
│ ├── service.properties # 服务个性化配置
│ ├── env.properties.example # 环境配置模板
│ └── service.properties.example # 服务配置模板
├── bootstrap.yml # 启动配置(新增)
└── logback-spring.xml # 更新:增强日志配置
├── application.yml # 主配置文件
├── application.yml.example # 主配置模板
├── bootstrap.yml # 启动配置(新增)
├── logback-spring.xml # 更新:增强日志配置
├── env.properties # 统一环境配置(敏感信息,不提交)
├── env.properties.example # 环境配置模板
├── service.properties # 服务个性化配置(敏感信息,不提交)
└── service.properties.example # 服务配置模板
deploy/ # 项目根目录
deploy/ # 项目根目录
└── scripts/
└── status.sh # 新增:状态查看脚本
└── status.sh # 新增:状态查看脚本
```
**部署阶段**(打包后):

View File

@ -42,33 +42,17 @@
<lineEnding>unix</lineEnding>
</fileSet>
<!-- 配置文件输出到 conf 目录 -->
<fileSet>
<directory>${project.basedir}/src/main/resources/conf</directory>
<outputDirectory>conf</outputDirectory>
<includes>
<include>*.properties</include>
<include>*.example</include>
</includes>
</fileSet>
<!-- application.yml 输出到 conf 目录 -->
<!-- 配置文件输出到 conf 目录(从 resources 目录获取) -->
<fileSet>
<directory>${project.basedir}/src/main/resources</directory>
<outputDirectory>conf</outputDirectory>
<includes>
<include>application.yml</include>
<include>application.yml.example</include>
<include>bootstrap.yml</include>
<include>logback-spring.xml</include>
</includes>
</fileSet>
<!-- 配置模板文件 -->
<fileSet>
<directory>${project.basedir}/../deploy/scripts</directory>
<outputDirectory>conf</outputDirectory>
<includes>
<include>*.example</include>
<include>env.properties.example</include>
<include>service.properties.example</include>
</includes>
</fileSet>
</fileSets>

View File

@ -1,38 +0,0 @@
# ====================================================
# 统一环境配置文件模板
# ====================================================
# 说明:
# 1. 复制此文件为 env.properties 并填入实际值
# 2. 此文件包含环境敏感配置,不提交到版本控制
# ====================================================
# ==================== 数据库配置 ====================
DB_HOST=localhost
DB_PORT=3306
DB_NAME=worklog
DB_USER=worklog
DB_PASSWORD=Wlog@123
# ==================== Redis 配置 ====================
REDIS_HOST=localhost
REDIS_PORT=6379
REDIS_PASSWORD=zjf@123456
REDIS_DATABASE=0
# ==================== Nacos 配置(可选)====================
NACOS_SERVER_ADDR=localhost:8848
NACOS_NAMESPACE=worklog-dev
NACOS_GROUP=DEFAULT_GROUP
NACOS_USERNAME=nacos
NACOS_PASSWORD=nacos
# ==================== JVM 配置 ====================
JVM_XMS=512m
JVM_XMX=1024m
JVM_METASPACE_SIZE=128m
JVM_MAX_METASPACE_SIZE=256m
JVM_GC_TYPE=G1GC
JVM_MAX_GC_PAUSE_MILLIS=200
# ==================== Spring 配置 ====================
SPRING_PROFILES_ACTIVE=prod

View File

@ -1,38 +0,0 @@
# ====================================================
# 服务个性化配置文件模板
# ====================================================
# 说明:
# 1. 复制此文件为 service.properties 并根据需要修改
# 2. 此文件优先级高于 env.properties
# 3. 用于覆盖默认配置或添加服务特定配置
# ====================================================
# ==================== Token 配置 ====================
# Token 有效期(秒),默认 24 小时
TOKEN_EXPIRE_TIME=86400
# Token 在 Redis 中的 Key 前缀
TOKEN_PREFIX=auth:token:
# ==================== 日志配置 ====================
# 日志内容最大长度(汉字)
LOG_MAX_CONTENT_LENGTH=2000
# ==================== 文件上传配置 ====================
# 是否启用本地文件上传
UPLOAD_ENABLED=true
# 上传文件存储路径
UPLOAD_BASE_PATH=./uploads
# 最大文件大小
UPLOAD_MAX_FILE_SIZE=10MB
# 允许的文件扩展名
UPLOAD_ALLOWED_EXTENSIONS=jpg,jpeg,png,gif,pdf,doc,docx,xls,xlsx
# ==================== 腾讯云 COS 配置(可选)====================
COS_ENABLED=false
COS_APP_ID=1308258046
COS_SECRET_ID=
COS_SECRET_KEY=
COS_BUCKET_NAME=
COS_BUCKET_HOST=
COS_REGION=ap-beijing