简体   繁体   English

无法解析Maven依赖项占位符参考值

[英]unable to resolve Maven dependency placeholder reference value

my project has dependencies on some framework jars: 我的项目依赖于一些框架罐:

<groupId>my-compamy</groupId>     
<artifactId>my-project</artifactId>         
<version>1.0</version>    
<dependency> 
    <groupId>my-company</groupId> 
    <artifactId>child-jar1</artifactId> 
    <version>2.0</version>
</dependency> 

recently the framework team changed their packaging, in the repository, they put a parent pom (used to be separated child jars) like this: 最近,框架团队更改了其包装,在存储库中,他们将一个父pom(以前是分开的子jar)放置如下:

<properties> 
    <reivison>2.0</revision> 
</properties>

<groupId>my-company</groupId>
<artifactId>framework-parent</artifactId>
<packaging>pom</packaging>
<version>${revision}</version>

<modules>
    <module>child-jar1</module>
</modules> 

in the child-jar1 pom: 在child-jar1 pom中:

<parent>
    <artifactId>framework-parent</artifactId>
    <groupId>my-company</groupId>
    <version>${revision}</version>  <!-- can find the value! -->
</parent> 

<artifactId>child-jar1</artifactId>
<packaging>jar</packaging>

When I build my-project, I got error message like: 当我构建项目时,出现如下错误消息:

... Failed to collect dependencies at my-company:child-jar1:jar:2.0. ...无法在my-company:child-jar1:jar:2.0上收集依赖项。

... cuased by: could not find framework-parent:pom ${revision} …归因于:找不到framework-parent:pom $ {revision}

and the child-jars are not downloaded. 并且未下载子jar。

it looks that it is the placeholder in the child pom caused the problem: my-project could not resolve the placeholder value in the dependent(chiild-jar1)'s pom. 似乎是子pom中的占位符引起了问题:my-project无法解析从属(chiild-jar1)pom中的占位符值。 tried multiple approaches to resolve the referenced value from my-project side but nothing worked. 尝试了多种方法来从我的项目侧解析参考值,但是没有任何效果。 Can this be resolved from my-project side without altering any dependency framework's setting? 可以在不更改任何依赖框架设置的情况下从my-project方面解决此问题吗? Please help. 请帮忙。

There is a way to replace the palceholder with concrete value: add flatten-maven-plugin in the framework parent pom file build section (first to run) - this does not impact the framework's functionality but has to be done in the framework side. 有一种方法可以用具体的值替换palceholder:在框架父pom文件构建部分(首先运行)中添加flatten-maven-plugin-这不会影响框架的功能,但必须在框架方面完成。 I gave this suggestion to the framework owner and they took it. 我将此建议提供给框架所有者,然后他们采纳了。 It works. 有用。

Thanks to all comment providers! 感谢所有评论提供者!

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM