在这边文章中,Maven profiles构建开发、集测、生产环境配置文件
另一种配置Maven profiles的方式如下:
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
</plugins>
<!-- 分环境 -->
<resources>
<resource>
<directory>src/main/resources/base</directory>
</resource>
<resource>
<directory>src/main/resources/${profilesActive}</directory>
</resource>
</resources>
<testResources>
<testResource>
<directory>src/main/resources/base</directory>
</testResource>
<testResource>
<directory>src/main/resources/${profilesActive}</directory>
</testResource>
</testResources>
</build>
<!-- 分环境部署 -->
<profiles>
<profile>
<id>dev</id>
<activation>
<activeByDefault>true</activeByDefault>
</activation>
<properties>
<profilesActive>dev</profilesActive>
</properties>
</profile>
<profile>
<id>test</id>
<properties>
<profilesActive>test</profilesActive>
</properties>
</profile>
<profile>
<id>stage</id>
<properties>
<profilesActive>stage</profilesActive>
</properties>
</profile>
<profile>
<id>prod</id>
<properties>
<profilesActive>prod</profilesActive>
</properties>
</profile>
</profiles>