Maven - 依赖继承 - 提供
我使用依赖项 POM,然后将其作为依赖项包含到另一个项目中。我遇到的问题是,当它聚合 POM 与这些依赖项时,当我声明范围的依赖项时,它就会出现,前提是这些依赖项不包括在内。
是否可以在依赖项 POM 中包含提供的依赖项,其范围为提供的?我经常声明我需要什么 API,然后将实现作为运行时依赖项包含在内。
I make use of dependency POMs which I will then go and include into another projects as as dependency. The problem I am having is while it aggregates the POM with those dependencies, it appears when I declare dependencies of scope, provided, those aren't included.
Is it possible to include provided dependencies in dependency POMs with a scope of provided? I often declare what APIs I need and then include the implementation as a runtime dependency.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
它以相同的范围继承。给定以下父级
pom.xml
:以及以下从根工件继承的
pom.xml
:从子级运行
mvn dependency:tree
给出以下输出:正如预期的那样,提供的 servlet-api 就在那里。
您可能(错误)使用了
dependencyManagement
部分吗?It is inherited with the same scope. Given the following parent
pom.xml
:And the following
pom.xml
that inherits from the root artifact:Running
mvn dependency:tree
from the child gives the following output:The provided
servlet-api
is there, as expected.Are you maybe (mis)using the
dependencyManagement
section?