这是我添加此变量的属性文件 的 databaseEnabled = $ {db.activedb}
我的属性文件的路径 的的src /主/资源/ application-dev.properties
这是我添加此代码的pom.xml
<build>
<finalName>spring-boot</finalName>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
</plugins>
<resources>
<resource>
<directory>src/main/resources</directory>
<filtering>true</filtering>
</resource>
<resource>
<directory>src/test/resources</directory>
<filtering>true</filtering>
</resource>
</resources>
</build>
<profiles>
<profile>
<id>dynamo</id>
<activation>
<property>
<name>env</name>
<value>dynamo</value>
</property>
</activation>
<properties>
<db.activedb>dynamodb</db.activedb>
</properties>
</profile>
<profile>
<id>mongo</id>
<activation>
<property>
<name>env</name>
<value>mongo</value>
</property>
</activation>
<properties>
<db.activedb>mongodb</db.activedb>
</properties>
</profile>
</profiles>
答案 0 :(得分:0)
添加includes
代码:
<resource>
<directory>src/main/resources</directory>
<filtering>true</filtering>
<includes>
<include>/application-dev.properties</include>
</includes>
</resource>
</resource>
使用-P
选项设置个人资料:
mvn package -P mongo
检查结果打开target/classes/application.properties
文件。