将依赖版本传播到 Maven 中的孙子模块
我有一个具有以下结构的项目:
Master (pom)
|_Project A (pom)
|_Project A1 (jar)
Project Master 管理依赖项 xyz 的版本。项目 A1 使用此依赖项,但构建已损坏,它抱怨依赖项 xyz 版本缺失。关于如何传播该版本有什么想法吗?任何帮助表示赞赏。
i have a project with the following structure:
Master (pom)
|_Project A (pom)
|_Project A1 (jar)
Project Master manages the version of dependency xyz. The project A1 uses this dependency, but the build is broken, it complains about dependency xyz version, that its missing. Any ideas on how to propagate that version? Any help appreciated.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
这是一个非常古老的问题,但我仍然觉得它很重要,因为最近我也发生了同样的事情。我的问题是我没有重建项目 A(孩子)。重建后,可以成功构建项目 A1(孙子),并且它现在使用 Master(父)中
dependencyManagement
部分的依赖项版本。A very old question, but I still find it relevant, as the same thing happened to me recently. My problem was that I hadn't rebuilt Project A (the child). After rebuilding it, Project A1 (grandchild) could be successfully built, and it's now using the dependency version from the
dependencyManagement
section in Master (parent).您提供的有关您的项目的信息非常少。听起来您想要的是 Master 有一个
为xyz
设置版本,然后指定
项目 A1 中的 code> 没有版本,让它通过 Master 中的声明进行依赖管理。您所需要的只是将项目 A 的父级设为 Master,将项目 A1 的父级设为项目 A。当然,项目 A 不得干扰工件xyz
的依赖关系管理。然后只需适当添加
和
即可。如果您认为您正在这样做,但它不起作用,请显示一些 POM 来说明您的问题。You've given very little information about your project. It sounds like what you want is for Master to have a
<dependencyManagement>
that sets a version forxyz
, and then specify the<dependency>
in Project A1 without a version, letting it be dependency-managed by the declaration in Master. All you need for that is for Project A's parent to be Master and Project A1's master to be Project A. And of course, Project A mustn't interfere with the dependency management of artifactxyz
. Then just add the<dependencyManagement>
and<dependency>
appropriately. If you think you're doing that, and it's not working, show some POMs that demonstrate your problem.