我正在使用基于 pom.xml 中存在的文件的激活。
但是,无论如何,我的配置文件始终会执行。
以下是个人资料描述:
<profile>
<id>copy</id>
<activation>
<file>
<exists>file.xml</exists>
</file>
</activation>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-antrun-plugin</artifactId>
<version>1.7</version>
<executions>
<execution>
<id>copy-resources</id>
<phase>validate</phase>
<configuration>
<target name="copy and rename file">
<copy file="${basedir}/src/main/resources/application.${env}.properties" tofile="${basedir}/src/main/fabric8/io.fabric8.system.properties" />
</target>
</configuration>
<goals>
<goal>run</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
</profile>
我这样称呼我的个人资料: mvn包-Pcopy
但是无论文件是否存在,配置文件都会被调用。 我做错了什么?
谢谢 罗曼。
最佳答案
如果项目中存在该文件,则运行 mvn
命令时无需传递配置文件名称。将 -Pcopy
显式传递给命令将覆盖 POM 中的激活
,并且始终激活此配置文件。
请参阅此 link 中的如何触发配置文件部分.
关于java - 使用文件存在忽略我的 Maven 配置文件中的激活(配置文件始终执行),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26126828/