【问题标题】:Properties defined in parent pom cannot be resolved/updated in child pom在父 pom 中定义的属性无法在子 pom 中解析/更新
【发布时间】:2018-10-11 12:27:53
【问题描述】:

父pom:

  <modelVersion>4.0.0</modelVersion>
  <groupId>xx.xxxx.xxxx.xx</groupId>
  <artifactId>parent-pom</artifactId>
  <version>0.0.1-SNAPSHOT</version>
  <packaging>pom</packaging>

   <properties>
        <properties_deinfed_in_parent_pom>1.0.2-SNAPSHOT</properties_deinfed_in_parent_pom>
   </properties>

孩子 pom:

<parent>
  <groupId>xx.xxxx.xxxx.xx</groupId>
  <artifactId>parent-pom</artifactId>
  <version>0.0.1-SNAPSHOT</version>
</parent>

<artifactId>child-pom</artifactId>
<packaging>war</packaging>
<version>${properties_deinfed_in_parent_pom}</version>

其中包括父pom,如果我更改父pom中的属性properties_deinfed_in_parent_pom,子pom中的版本将不会更新。我可以更新的唯一方法是在 maven 命令中使用 -Dxxx=value 。我还检查了有效的pom,它也没有更新。那么这个想法是否会像我的期望一样起作用,或者我认为是错误的。

我使用 Maven 3.3.x、IntelliJ 2018.1

【问题讨论】:

  • 能否请您也显示来自父 pom 的相应代码?

标签: java maven properties parent-pom


【解决方案1】:

父 pom 需要指定模块列表。将以下内容添加到父 pom 中

<modules> <module>child-pom</module> </modules>

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2020-04-11
    • 2012-03-31
    • 2018-08-09
    • 2021-06-26
    • 2018-07-23
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多