Maven的 - 从孩子POM的父POM访问属性 [英] Maven - Access properties on parent pom from a child pom

查看:1310
本文介绍了Maven的 - 从孩子POM的父POM访问属性的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在一个多模块项目结构

 对myApp
| -moduleA
| ---的pom.xml
| -moduleB
| ---的pom.xml
| -pom.xml

如果我在parent.pom以下属性

 <性状>
   < moduleA.version> 4.67 LT; /moduleA.version>
   < moduleB.version>&4.68 LT; /moduleB.version>
  < /性状>

我如何可以访问父POM的属性从任何孩子多金属氧酸盐?我想这对孩子聚甲醛,但它没有工作。

 <&的groupId GT; com.test< /的groupId>
  <&的artifactId GT; moduleA< / artifactId的>
  <&版GT; $ {moduleA.version}< /版本>


解决方案

如果你有一个真正的多模块构建你永远不应该定义模块有不同的版本。它们应具有相同的版本,这使释放可能和其他东西,以及。否则,你不应该使用多模块的设置比使用的分离简单的单模块。

In a multi module project structure as

myApp
|-moduleA
|---pom.xml
|-moduleB
|---pom.xml
|-pom.xml

If i have the following properties in the parent.pom

  <properties>
   <moduleA.version>4.67</moduleA.version>
   <moduleB.version>4.68</moduleB.version>
  </properties>  

How can i access the properties in the parent pom from any of the child poms? I tried this on the child pom but it didnt work.

  <groupId>com.test</groupId>
  <artifactId>moduleA</artifactId>
  <version>${moduleA.version}</version>

解决方案

If you have a real multi-module build you should never define the modules to have different versions. They should have the same version which make releasing possible and other things as well. Otherwise you should not use the multi-module setup than use simple single modules which are separated.

这篇关于Maven的 - 从孩子POM的父POM访问属性的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆