使用文件存在忽略我的 Maven 配置文件中的激活(配置文件始终执行)

Tom*_*r99 2 java activation maven-plugin maven

我正在使用基于 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>
Run Code Online (Sandbox Code Playgroud)

我这样称呼我的个人资料: mvn package -Pcopy

但是无论文件是否存在,总是会调用配置文件。我究竟做错了什么?

谢谢罗曼。

man*_*uti 5

mvn如果文件存在于项目中,则在运行命令时不需要传递配置文件名称。-Pcopy显式传递给命令将覆盖activationPOM 中的 ,并将始终激活此配置文件。

请参阅此链接中的如何触发配置文件部分。