feat: 添加 Maven Assembly 打包配置
- 添加 assembly.xml 定义标准部署目录结构 - 配置 pom.xml 使用 maven-assembly-plugin - 打包输出到 deploy/worklog-api/ 目录 - 目录结构:bin/ lib/ conf/ - 更新 start.sh 脚本适配 lib/ 目录 - 添加 env.properties.example 和 service.properties.example 配置模板 - 更新 .gitignore 忽略打包输出目录
This commit is contained in:
parent
4b4fcf2ead
commit
ae7fb43e39
3
.gitignore
vendored
3
.gitignore
vendored
@ -58,6 +58,9 @@ src/main/resources/conf/service.properties
|
||||
*.sql.backup
|
||||
db_backup/
|
||||
|
||||
# ==================== Assembly 打包输出 ====================
|
||||
deploy/worklog-api/
|
||||
|
||||
# ==================== 上传文件 ====================
|
||||
uploads/
|
||||
files/
|
||||
|
||||
@ -7,7 +7,7 @@
|
||||
APP_NAME="worklog-api"
|
||||
APP_JAR="worklog-api-1.0.0.jar"
|
||||
APP_HOME="/opt/worklog/${APP_NAME}"
|
||||
APP_JAR_PATH="${APP_HOME}/${APP_JAR}"
|
||||
APP_JAR_PATH="${APP_HOME}/lib/${APP_JAR}"
|
||||
|
||||
# 配置文件加载函数
|
||||
load_properties() {
|
||||
|
||||
@ -124,6 +124,30 @@
|
||||
</excludes>
|
||||
</configuration>
|
||||
</plugin>
|
||||
|
||||
<!-- Maven Assembly Plugin - 打包为标准部署目录结构 -->
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-assembly-plugin</artifactId>
|
||||
<version>3.6.0</version>
|
||||
<configuration>
|
||||
<descriptors>
|
||||
<descriptor>src/main/assembly/assembly.xml</descriptor>
|
||||
</descriptors>
|
||||
<outputDirectory>${project.basedir}/../deploy</outputDirectory>
|
||||
<appendAssemblyId>false</appendAssemblyId>
|
||||
<finalName>worklog-api</finalName>
|
||||
</configuration>
|
||||
<executions>
|
||||
<execution>
|
||||
<id>make-assembly</id>
|
||||
<phase>package</phase>
|
||||
<goals>
|
||||
<goal>single</goal>
|
||||
</goals>
|
||||
</execution>
|
||||
</executions>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</build>
|
||||
</project>
|
||||
|
||||
76
worklog-api/src/main/assembly/assembly.xml
Normal file
76
worklog-api/src/main/assembly/assembly.xml
Normal file
@ -0,0 +1,76 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<assembly xmlns="http://maven.apache.org/ASSEMBLY/2.2.0"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://maven.apache.org/ASSEMBLY/2.2.0 https://maven.apache.org/xsd/assembly-2.2.0.xsd">
|
||||
|
||||
<id>dist</id>
|
||||
<formats>
|
||||
<format>dir</format>
|
||||
</formats>
|
||||
|
||||
<!-- 不包含基础目录 -->
|
||||
<includeBaseDirectory>false</includeBaseDirectory>
|
||||
|
||||
<!-- 输出目录名 -->
|
||||
<baseDirectory>worklog-api</baseDirectory>
|
||||
|
||||
<fileSets>
|
||||
<!-- JAR 包输出到 lib 目录 -->
|
||||
<fileSet>
|
||||
<directory>${project.build.directory}</directory>
|
||||
<outputDirectory>lib</outputDirectory>
|
||||
<includes>
|
||||
<include>*.jar</include>
|
||||
</includes>
|
||||
<excludes>
|
||||
<exclude>*-sources.jar</exclude>
|
||||
<exclude>*-javadoc.jar</exclude>
|
||||
</excludes>
|
||||
</fileSet>
|
||||
|
||||
<!-- 启动脚本输出到 bin 目录 -->
|
||||
<fileSet>
|
||||
<directory>${project.basedir}/../deploy/scripts</directory>
|
||||
<outputDirectory>bin</outputDirectory>
|
||||
<includes>
|
||||
<include>start.sh</include>
|
||||
<include>stop.sh</include>
|
||||
<include>restart.sh</include>
|
||||
<include>status.sh</include>
|
||||
</includes>
|
||||
<fileMode>0755</fileMode>
|
||||
<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 目录 -->
|
||||
<fileSet>
|
||||
<directory>${project.basedir}/src/main/resources</directory>
|
||||
<outputDirectory>conf</outputDirectory>
|
||||
<includes>
|
||||
<include>application.yml</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>
|
||||
</includes>
|
||||
</fileSet>
|
||||
</fileSets>
|
||||
|
||||
</assembly>
|
||||
38
worklog-api/src/main/resources/conf/env.properties.example
Normal file
38
worklog-api/src/main/resources/conf/env.properties.example
Normal file
@ -0,0 +1,38 @@
|
||||
# ====================================================
|
||||
# 统一环境配置文件模板
|
||||
# ====================================================
|
||||
# 说明:
|
||||
# 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
|
||||
@ -0,0 +1,38 @@
|
||||
# ====================================================
|
||||
# 服务个性化配置文件模板
|
||||
# ====================================================
|
||||
# 说明:
|
||||
# 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
|
||||
Loading…
x
Reference in New Issue
Block a user