build: 分环境打包 (Maven profile 注入激活 profile, jar 名加 -test/-prod 后缀)
- ry-api/pom.xml 新增 test/prod profile, 提供 active.profile 与 jar.suffix - ruoyi-admin 资源过滤仅针对 application*.yml, finalName 追加 jar.suffix - application.yml 的 spring.profiles.active 改用 @active.profile@, 免运行时 --spring.profiles.active Co-Authored-By: Claude Code <noreply@anthropic.com>
This commit is contained in:
@@ -31,6 +31,10 @@
|
|||||||
<jwt.version>0.9.1</jwt.version>
|
<jwt.version>0.9.1</jwt.version>
|
||||||
<jaxb-api.version>2.3.1</jaxb-api.version>
|
<jaxb-api.version>2.3.1</jaxb-api.version>
|
||||||
<springdoc.version>3.0.3</springdoc.version>
|
<springdoc.version>3.0.3</springdoc.version>
|
||||||
|
<!-- 打包注入的激活 profile: 默认 prod, -Ptest / -Pprod 覆盖 -->
|
||||||
|
<active.profile>prod</active.profile>
|
||||||
|
<!-- jar 名后缀: 默认空 (=ruoyi-admin.jar), -Ptest → -test, -Pprod → -prod -->
|
||||||
|
<jar.suffix></jar.suffix>
|
||||||
</properties>
|
</properties>
|
||||||
|
|
||||||
<!-- 依赖声明 -->
|
<!-- 依赖声明 -->
|
||||||
@@ -215,6 +219,24 @@
|
|||||||
</plugins>
|
</plugins>
|
||||||
</build>
|
</build>
|
||||||
|
|
||||||
|
<!-- 分环境打包: mvn package -Ptest / -Pprod 生成 ruoyi-admin-test.jar / ruoyi-admin-prod.jar (profile 已注入, 免 spring.profiles.active 启动参数) -->
|
||||||
|
<profiles>
|
||||||
|
<profile>
|
||||||
|
<id>test</id>
|
||||||
|
<properties>
|
||||||
|
<active.profile>test</active.profile>
|
||||||
|
<jar.suffix>-test</jar.suffix>
|
||||||
|
</properties>
|
||||||
|
</profile>
|
||||||
|
<profile>
|
||||||
|
<id>prod</id>
|
||||||
|
<properties>
|
||||||
|
<active.profile>prod</active.profile>
|
||||||
|
<jar.suffix>-prod</jar.suffix>
|
||||||
|
</properties>
|
||||||
|
</profile>
|
||||||
|
</profiles>
|
||||||
|
|
||||||
<repositories>
|
<repositories>
|
||||||
<repository>
|
<repository>
|
||||||
<id>public</id>
|
<id>public</id>
|
||||||
|
|||||||
@@ -63,6 +63,23 @@
|
|||||||
</dependencies>
|
</dependencies>
|
||||||
|
|
||||||
<build>
|
<build>
|
||||||
|
<!-- 仅过滤 application*.yml 注入 @active.profile@, 其余资源 (logback/mapper/i18n) 不过滤避免误替换 ${...} -->
|
||||||
|
<resources>
|
||||||
|
<resource>
|
||||||
|
<directory>src/main/resources</directory>
|
||||||
|
<filtering>true</filtering>
|
||||||
|
<includes>
|
||||||
|
<include>application*.yml</include>
|
||||||
|
</includes>
|
||||||
|
</resource>
|
||||||
|
<resource>
|
||||||
|
<directory>src/main/resources</directory>
|
||||||
|
<filtering>false</filtering>
|
||||||
|
<excludes>
|
||||||
|
<exclude>application*.yml</exclude>
|
||||||
|
</excludes>
|
||||||
|
</resource>
|
||||||
|
</resources>
|
||||||
<plugins>
|
<plugins>
|
||||||
<plugin>
|
<plugin>
|
||||||
<groupId>org.springframework.boot</groupId>
|
<groupId>org.springframework.boot</groupId>
|
||||||
@@ -89,7 +106,7 @@
|
|||||||
</configuration>
|
</configuration>
|
||||||
</plugin>
|
</plugin>
|
||||||
</plugins>
|
</plugins>
|
||||||
<finalName>${project.artifactId}</finalName>
|
<finalName>${project.artifactId}${jar.suffix}</finalName>
|
||||||
</build>
|
</build>
|
||||||
|
|
||||||
</project>
|
</project>
|
||||||
@@ -6,8 +6,8 @@ spring:
|
|||||||
# 国际化资源文件路径
|
# 国际化资源文件路径
|
||||||
basename: i18n/messages
|
basename: i18n/messages
|
||||||
profiles:
|
profiles:
|
||||||
# 默认 prod 环境; 本地测试用 --spring.profiles.active=test (group 自动展开为 druid,test)
|
# 默认 prod; Maven 打包时用 -Ptest/-Pprod 注入 @active.profile@ (见 pom.xml profiles), 免运行时 --spring.profiles.active
|
||||||
active: prod
|
active: @active.profile@
|
||||||
group:
|
group:
|
||||||
test: druid,test
|
test: druid,test
|
||||||
prod: druid,prod
|
prod: druid,prod
|
||||||
|
|||||||
Reference in New Issue
Block a user