这样的财产是否会覆盖Maven3中的工作?

时间:2016-04-21 11:13:39

标签: java maven maven-3

我有一个父pom.xml,其中包含${targetJdk}的build / pluginManagement / plugins / plugin部分。它包含依赖于属性maven-compiler-plugin的配置,该属性也在父pom中定义。

我有一个孩子的pom.xml,它使用来自父母的${targetJdk}。 但是子pom.xml用其他值覆盖<properties> <targetJdk>1.8</targetJdk> </properties> <build> <pluginManagement> <plugins> <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-compiler-plugin</artifactId> <version>3.1</version> <configuration> <source>${targetJdk}</source> <target>${targetJdk}</target> <debug>true</debug> <showDeprecation>true</showDeprecation> <showWarnings>true</showWarnings> <fork>true</fork> </configuration> </plugin> </plugins> </pluginManagement> </build> 属性。

父:

<properties>
    <targetJdk>1.7</targetJdk>
</properties>
<build>
    <plugins>
        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-compiler-plugin</artifactId>
        </plugin>
    </plugins>
</build>

子:

MimeBodyPart messageBodyPart = new MimeBodyPart();

所以问题是:当我构建一个子工件时,它将使用什么属性值?

2 个答案:

答案 0 :(得分:2)

通常,当您在子pom中声明相同的插件和/或属性时,您将覆盖父级。

您的孩子将使用<targetJdk>1.7</targetJdk>

我希望这会有所帮助。

答案 1 :(得分:2)

确定总是使用有效的Pom

帮助:有效,聚甲醛