Dan*_*lor 39 maven-3 maven build-dependencies
如何${project.version}
从父pom中为托管属性解析占位符?我期望它在全局范围内得到解决,因此当父pom具有版本2时,${project.version}
也将被解析为版本2.
在父母pom我有:
<groupId>my.group</groupId>
<artifactId>parent</artifactId>
<version>2</version>
<packaging>pom</packaging>
<dependencyManagement>
<dependencies>
<dependency>
<groupId>my.group</groupId>
<artifactId>dep</artifactId>
<version>${project.version}</version>
</dependency>
</dependencies>
</dependencyManagement>
Run Code Online (Sandbox Code Playgroud)
在我使用的孩子
<parent>
<groupId>my.group</groupId>
<artifactId>parent</artifactId>
<version>2</version>
</parent>
<version>1</version>
<artifactId>child</artifactId>
Run Code Online (Sandbox Code Playgroud)
但是使用了工件my.group.dep.1.jar
而不是my.group.dep.2.jar
.因此,占位符使用托管依赖项解析为项目版本,而不是定义依赖项的项目版本.
这是预期的行为吗?我正在使用maven 3.0.4.
Ter*_*for 34
你必须跳过<version>
孩子的<parent><version> ... </parent>
标签,但保留标签.
http://maven.apache.org/guides/introduction/introduction-to-the-pom.html#Project_Inheritance
需要注意的一个因素是,如上所述,这些变量在继承之后进行处理.这意味着如果父项目使用变量,那么它在子项中的定义(而不是父项)将是最终使用的定义.
归档时间: |
|
查看次数: |
72716 次 |
最近记录: |