Maven的。传递依赖 [英] Maven. Transitive dependencies
问题描述
NoClassDefFoundError
,这是由于缺少B jar。 不应该Maven已经自动下载了这些依赖关系?
我的项目P依赖于依赖关系A [范围]取决于依赖B [具有编译范围]。
除非B是 的maven.apache.org/guides/introduction/introduction-to-dependency-mechanism.html#Transitive_Dependenciesrel =noreferrer> P具有compile(*)范围(参见依赖范围并阅读注释),因此应该在运行时可用。
但是,抛出了一个NoClassDefFoundError在P,w的运行时间
由于您在Eclipse下运行该项目,所以类路径是为您设置的,所以我'将排除此级别的错误。这使我们有可选的依赖关系。
PS:调查这种问题的一个非常有用的工具是依赖:tree
。
My project P depends on dependency A which depends on dependency B. My project's pom.xml file includes A as a dependency, and its jar is included in P's classpath. However, there is a NoClassDefFoundError
thrown at runtime of P, which stems from missing B jars.
Shouldn't Maven have downloaded these dependencies automatically?
My project P depends on dependency A [with a compile scope] which depends on dependency B [with a compile scope].
Unless B is an optional dependency of A, B should be a dependency of P with a "compile(*)" scope (see the table of Dependency Scope and read the note) and should thus be available at runtime.
However, there is a NoClassDefFoundError thrown at runtime of P, which stems from missing B jars.
Since you're running the project under Eclipse, the class path is setup for you so I'll exclude a mistake at this level. This leaves us with the case of the optional dependency.
PS: A very useful tool to investigate this kind of problem is dependency:tree
.
这篇关于Maven的。传递依赖的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!