<profiles>
<profile>
<id>dev</id>
<activation>
<activeByDefault>true</activeByDefault>
</activation>
<properties>
<env>dev</env>
<version>${project.version}</version>
</properties>
</profile>
<profile>
<id>test</id>
<properties>
<env>prepub</env>
<version>${project.version}</version>
</properties>
</profile>
</profiles>
- SpringBoot项目application.properties配置,读取pom中环境信息
#读取profile中配置的properties变量或者pom中properties配置的属性
spring.profiles.active=@env@
project.version=@version@
- 根据环境信息排除项目用不到的properties配置文件
<resources>
<resource>
<directory>src/main/resources</directory>
<filtering>true</filtering>
<excludes>
<exclude>application-dev.properties</exclude>
<exclude>application-test.properties</exclude>
</excludes>
</resource>
<resource>
<directory>src/main/resources</directory>
<filtering>true</filtering>
<includes>
<include>application-${env}.properties</include>
</includes>
</resource>
</resources>
网友评论