Java 使用file exist忽略我的maven概要文件中的激活(始终执行概要文件)
我正在使用基于pom.xml中存在的文件的激活 但是,无论发生什么情况,我的配置文件始终被执行 以下是配置文件说明:Java 使用file exist忽略我的maven概要文件中的激活(始终执行概要文件),java,maven,maven-plugin,activation,Java,Maven,Maven Plugin,Activation,我正在使用基于pom.xml中存在的文件的激活 但是,无论发生什么情况,我的配置文件始终被执行 以下是配置文件说明: <profile> <id>copy</id> <activation> <file> <exists>file.xml</exists> </file> </activation> &
<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>
复制
file.xml
org.apache.maven.plugins
maven antrun插件
1.7
复制资源
验证
跑
我这样称呼我的个人资料:
mvn包-Pcopy
但是不管文件是否存在,配置文件总是被调用。
我做错了什么
谢谢
Romain。如果项目中存在文件,则在运行
mvn
命令时不需要传递配置文件名。将-Pcopy
显式传递给命令将覆盖POM中的激活
,并始终激活此配置文件
请参阅本节中的“如何触发配置文件”。接下来,内部化激活配置文件比调用或执行配置文件更有利。这种匹配更好地体现了POM的声明性,而不是命令性。也许你已经意识到它已经通过POM激活了