我在项目的资源目录中有一个属性文件,并希望在基于概要文件的项目构建时通过maven命令写入一些属性值。属性文件如下所示(application.properties):
server.port=${server.port}
report.workspacePath=${reporting.workspacePath}
server.path=/foo/foosame
server.filePath=/bar/bardir
这是我的pom文件的样子:
<profiles>
<profile>
<id>server</id>
<properties>
<server.port>8080</server.port>
<reporting.workspacePath>/opt/reporting/backend2-instance/reporting</reporting.workspacePath>
</properties>
</profile>
<profile>
<id>staging</id>
<properties>
<server.port>8084</server.port>
<reporting.workspacePath>/opt/reporting/backend1-instance/reporting</reporting.workspacePath>
</properties>
</profile>
</profiles>
<build>
<resources>
<resource>
<directory>src/main/resources</directory>
<!--<excludes>
<exclude>*.properties</exclude>
</excludes> -->
<filtering>true</filtering>
</resource>
</resources>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
<plugin>
<artifactId>maven-resources-plugin</artifactId>
<version>3.0.2</version>
<executions>
<execution>
<id>copy-resources</id>
<phase>compile</phase>
<goals>
<goal>copy-resources</goal>
</goals>
<configuration>
<outputDirectory>${basedir}/target/</outputDirectory>
<resources>
<resource>
<directory>src/main/resources</directory>
<excludes>
<exclude>*.txt</exclude>
</excludes>
<filtering>true</filtering>
</resource>
</resources>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
但是当我像这样运行maven命令时,什么也没有写入属性文件中:
mvn -Pstaging clean package
有人可以知道我在这里缺少什么吗?