【问题标题】:Dependency of Type "POM"“POM”类型的依赖
【发布时间】:2020-04-09 19:29:53
【问题描述】:

我正在尝试使用 ServiceMix 和 ActiveMQ 运行 ESB 系统。但即使在我走到那一步之前,我也有一个关于 POM 依赖类型的问题。我得到了maven依赖:

<!-- https://mvnrepository.com/artifact/org.apache.servicemix/servicemix -->
<dependency>
    <groupId>org.apache.servicemix</groupId>
    <artifactId>servicemix</artifactId>
    <version>7.0.1</version>
    <type>pom</type>
</dependency>

现在,当我在包含此依赖项的项目上运行“全新安装”时,我没有看到任何 activeMQ jar 被复制到类路径中或可用于编译(我已经编写了复制依赖项,所以我可以看到包含哪些 jar 文件)。在这种情况下,我是否仍然需要在我的 pom 文件中明确提及 activeMQ 依赖项?喜欢:

<!-- https://mvnrepository.com/artifact/org.apache.activemq/activemq-core -->
<dependency>
    <groupId>org.apache.activemq</groupId>
    <artifactId>activemq-core</artifactId>
</dependency>

任何指导将不胜感激。这个 ServiceMix 因缺少文档而令人沮丧。

【问题讨论】:

  • 我看了那个答案和其他一些类似的答案。我确实在我的父项目中包含dependencyManagement 下的依赖项,并尝试在我的子模块中使用import 范围,但我收到错误org.apache.servicemix:servicemix:pom must be one of [provided, compile, runtime, test, system] but is 'import'. 所以该解决方案没有帮助

标签: java maven


【解决方案1】:

如果您将pom 类型的依赖项放入您的&lt;dependencies&gt;,Maven 将使用 POM 的内容作为传递依赖项。因此,该 POM 中的所有内容都将成为类路径的一部分,除非它具有 test 范围之类的内容,或者它的版本被 POM 的其他部分覆盖。

将 POM 放入 &lt;dependencyManagement&gt; 是另一回事。请注意,import 范围仅适用于 &lt;dependencyManagement&gt;。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2016-12-18
    • 1970-01-01
    • 2015-11-28
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2019-06-06
    相关资源
    最近更新 更多