【发布时间】:2015-10-19 19:27:19
【问题描述】:
我正在尝试使用 org.jboss.bom 组中的一些 BOM 来引入与 EAP 6.3.0 兼容的 API 堆栈。我的理解是,这就是他们的目的。但是当我引用它们时(使用“提供”甚至“编译”范围),依赖关系不会变得可传递。鉴于在 BOM 内的项目上使用了“编译”范围,依赖机制的 Maven's documentation 似乎表明这些项目应该添加到我的项目的类路径中。然而,对于应该引入的类,我得到了未定义的符号。
例如,在项目 P 中,我将 org.jboss.bom.wfk:jboss-javaee-6.0-with-spring:2.4.0-redhat-2 包含在“提供”范围内,但包含 org.springframework。 context.ApplicationContext 在 P 中未定义。
这一切都发生在 JBoss Dev Studio 8.1.0.GA 中,如果这有所作为的话。
【问题讨论】:
-
using 'provided' scope确实在这里有所作为。 -
@Tome 我不认为“提供”的不同解释了我所看到的。但是感谢您让我重新阅读了 Maven 文档中的表格,因为我现在可以更清楚地描述我的问题。当 BOM 中的依赖项范围未指定时,我不知何故认为该表给了我一个特定的结果。相应地编辑描述...
-
m2e 插件版本为:m2e 1.5.1、m2e wtp 1.1.0、org.jboss.tools.maven.* 1.6.2-Final
-
如果你指定一个没有作用域的依赖,它的作用域是
compile(实际上也是运行时)。如果您将依赖项指定为provided,则不会传递地添加其自身的依赖项。 Maven 文档中的表格可能不清楚,但它的工作原理是这样的。 -
@Tome 查看原始文档:
This is much like compile, but indicates you expect the JDK or a container to provide the dependency at runtime. For example, when building a web application for the Java Enterprise Edition, you would set the dependency on the Servlet API and related Java EE APIs to scope provided because the web container provides those classes. This scope is only available on the compilation and test classpath, and is not transitive.maven dependency mechanism
标签: maven jboss7.x jboss-eap-6