Maven. Transitive dependencies

后端 未结 4 1930
时光说笑
时光说笑 2020-12-14 06:33

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. Howev

4条回答
  •  既然无缘
    2020-12-14 06:48

    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.

提交回复
热议问题