35

如果我们考虑以下示例,“+-”和“\-”符号之间有什么区别,它们表示什么?

[INFO] [dependency:tree]
[INFO] org.apache.maven.plugins:maven-dependency-plugin:maven-plugin:2.0-alpha-5-SNAPSHOT
[INFO] +- org.apache.maven.reporting:maven-reporting-impl:jar:2.0.4:compile
[INFO] |  \- commons-validator:commons-validator:jar:1.2.0:compile
[INFO] |     \- commons-digester:commons-digester:jar:1.6:compile
[INFO] |        \- (commons-collections:commons-collections:jar:2.1:compile - omitted for conflict with 2.0)
[INFO] \- org.apache.maven.doxia:doxia-site-renderer:jar:1.0-alpha-8:compile
[INFO]    \- org.codehaus.plexus:plexus-velocity:jar:1.1.3:compile
[INFO]       \- commons-collections:commons-collections:jar:2.0:compile
4

5 回答 5

43

这些符号没有任何意义,它们只是为了更好地阅读树的输出而存在!

这是一个更复杂的输出,可以更好地了解它的spring-webmvc依赖关系:

[INFO] +- org.springframework:spring-webmvc:jar:4.2.2.RELEASE:compile
[INFO] |  +- org.springframework:spring-beans:jar:4.2.2.RELEASE:compile
[INFO] |  +- org.springframework:spring-context:jar:4.2.2.RELEASE:compile
[INFO] |  |  \- org.springframework:spring-aop:jar:4.2.2.RELEASE:compile
[INFO] |  |     \- aopalliance:aopalliance:jar:1.0:compile
[INFO] |  +- org.springframework:spring-core:jar:4.2.2.RELEASE:compile
[INFO] |  |  \- commons-logging:commons-logging:jar:1.2:compile
[INFO] |  +- org.springframework:spring-expression:jar:4.2.2.RELEASE:compile

将依赖树视为层次:第一层次对应于直接依赖关系;第二级对应于那些直接依赖的传递依赖等。

基本上,如果同一工件在同一级别上存在多个依赖项,+-则将显示 a,否则\-将显示 a,指示树的“结束”(即通向叶子的路径)。

于 2015-11-30T19:53:03.900 回答
27

\-符号表示该节点是为当前父节点列出的最后一个兄弟节点

于 2016-01-22T18:36:18.167 回答
7

加号表示同一级别上的多个节点,而该-符号表示该层次结构级别的一个节点。

因此,在您的情况下,maven-dependency-plugin( +symbol) 具有传递依赖关系maven-reporting-impl,并且doxia-site-renderer在第一级,maven-reporting-impl只有 ( -symbol)commons-validator作为直接传递依赖关系,依此类推。

于 2015-11-30T19:53:33.227 回答
0

对于同一级别的多个依赖项,\-将显示该级别的最后一个依赖项,并将+-显示该级别的所有其他依赖项。

于 2021-07-21T19:04:03.140 回答
-1

也许“+-”表示树层次结构中的非最后一个节点

"\-" 表示树层次结构中的最后一个节点

我猜他可能会使用某种尾部是索引的数据结构。

例如

root:
....+-(first chirld)
....+-(second chirld)
........\-(last chirld)
....\-(last chirld)

这是关于 [maven-dependency-tree][https://github.com/apache/maven-dependency-tree] 依赖项的更复杂的输出:

[INFO] Scanning for projects...
[INFO]
[INFO] -----------< org.apache.maven.shared:maven-dependency-tree >------------
[INFO] Building Apache Maven Dependency Tree 3.1.1-SNAPSHOT
[INFO] --------------------------------[ jar ]---------------------------------
[INFO]
[INFO] --- maven-dependency-plugin:3.1.1:tree (default-cli) @ maven-dependency-tree ---
[INFO] org.apache.maven.shared:maven-dependency-tree:jar:3.1.1-SNAPSHOT
[INFO] +- org.apache.maven:maven-core:jar:3.0.5:compile
[INFO] |  +- org.apache.maven:maven-model:jar:3.0.5:compile
[INFO] |  +- org.apache.maven:maven-settings:jar:3.0.5:compile
[INFO] |  +- org.apache.maven:maven-settings-builder:jar:3.0.5:compile
[INFO] |  +- org.apache.maven:maven-repository-metadata:jar:3.0.5:compile
[INFO] |  +- org.apache.maven:maven-artifact:jar:3.0.5:compile
[INFO] |  +- org.apache.maven:maven-plugin-api:jar:3.0.5:compile
[INFO] |  +- org.apache.maven:maven-model-builder:jar:3.0.5:compile
[INFO] |  +- org.apache.maven:maven-aether-provider:jar:3.0.5:compile
[INFO] |  |  \- org.sonatype.aether:aether-spi:jar:1.13.1:compile
[INFO] |  +- org.sonatype.aether:aether-impl:jar:1.13.1:compile
[INFO] |  +- org.sonatype.aether:aether-util:jar:1.13.1:compile
[INFO] |  +- org.sonatype.sisu:sisu-inject-plexus:jar:2.3.0:compile
[INFO] |  |  \- org.sonatype.sisu:sisu-inject-bean:jar:2.3.0:compile
[INFO] |  |     \- org.sonatype.sisu:sisu-guice:jar:no_aop:3.1.0:compile
[INFO] |  |        \- org.sonatype.sisu:sisu-guava:jar:0.9.9:compile
[INFO] |  +- org.codehaus.plexus:plexus-interpolation:jar:1.14:compile
[INFO] |  +- org.codehaus.plexus:plexus-utils:jar:2.0.6:compile
[INFO] |  +- org.codehaus.plexus:plexus-classworlds:jar:2.4:compile
[INFO] |  \- org.sonatype.plexus:plexus-sec-dispatcher:jar:1.3:compile
[INFO] |     \- org.sonatype.plexus:plexus-cipher:jar:1.4:compile
[INFO] +- org.codehaus.plexus:plexus-component-annotations:jar:2.0.0:compile (optional)
[INFO] +- org.sonatype.aether:aether-api:jar:1.13.1:compile (optional)
[INFO] +- org.eclipse.aether:aether-api:jar:1.1.0:compile (optional)
[INFO] \- org.eclipse.aether:aether-util:jar:1.1.0:compile
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 8.519 s
[INFO] Finished at: 2021-12-27T16:06:44+08:00
[INFO] ------------------------------------------------------------------------

于 2021-12-27T08:23:11.113 回答