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

标签 java maven maven-plugin activation

我正在使用基于 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/

相关文章:

java - 无法使用 TestRestTemplate Jar 冲突测试 Spring Boot Jersey Rest API

xml - 您能否将 Maven pom.xml 文件重构为可重用的 XML 片段?

java - 在父 pom 中定义 Maven 插件配置并在子 pom 中设置其激活条件

java - 即使在自定义插件中使用显式绑定(bind),m2e 仍然会报错 "Plugin execution not covered by lifecycle configuration"

java - antlr:生成的 Lexer 源中缺少包声明

java - 基本Java : While loop for basic quiz?

java - 使用 JAVA 以编程方式将 S3 对象(公共(public) URL)发送至 Google 云存储

java - Android:包含/重新打包引用 javax 核心类的依赖项时出错

java - NetBeans 更改 Ant 版本

maven - Spring 启动 : is there a way to show the POM version number in some endpoint easily?