javaSpringBoot项目多环境配置
- 为什么
-
- [maven Profiles 救命](#maven Profiles 救命)
- 项目的pom文件管理
为什么
项目里面需要集成测试环境、开发、生产、多云环境,不仅需要application.yml,还需要加载别的config配置文件
故,我需要便捷多环境配置管理
maven Profiles 救命
项目的pom文件管理
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<configuration>
<excludes>
<exclude>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
</exclude>
</excludes>
</configuration>
</plugin>
</plugins>
<!--uuuuu-->
<resources>
<resource>
<directory>src/main/resources</directory>
<filtering>true</filtering>
</resource>
<!-- 使用@@站位符,输出Dockerfile至docker文件夹 -->
<resource>
<directory>src/main/docker</directory>
<filtering>true</filtering>
<includes>
<include>**/*</include>
</includes>
<targetPath>../docker</targetPath>
</resource>
<resource>
<directory>src/main/resources</directory>
<includes>
<include>**/*</include>
</includes>
<excludes>
<exclude>env/**</exclude>
<exclude>.gitkeep</exclude>
</excludes>
<filtering>true</filtering>
</resource>
<resource>
<directory>src/main/resources/env/${env}</directory>
</resource>
</resources>
</build>
<profiles>
<profile>
<id>dev</id>
<properties>
<env>dev</env>
</properties>
<activation>
<activeByDefault>true</activeByDefault>
</activation>
</profile>
<profile>
<id>test</id>
<properties>
<env>test</env>
</properties>
</profile>
<profile>
<id>xrytest</id>
<properties>
<env>xrytest</env>
</properties>
</profile>
<profile>
<id>prd</id>
<properties>
<env>prd</env>
</properties>
</profile>
</profiles>