$ mvn dependency:tree [WARNING] [WARNING] Some problems were encountered while building the effective settings [WARNING] Unrecognised tag: 'properties' (position: START_TAG seen ...</profile>\n\t <properties>.. @85:18) @ C:\Users\qhong\.m2\settings.xml, line 85, column 18 [WARNING] [INFO] Scanning for projects... [INFO] [INFO] -----------------------< com.xuxueli:xxl-excel >------------------------ [INFO] Building xxl-excel 1.1.2-SNAPSHOT [INFO] --------------------------------[ jar ]--------------------------------- [INFO] [INFO] --- maven-dependency-plugin:2.8:tree (default-cli) @ xxl-excel --- [INFO] com.xuxueli:xxl-excel:jar:1.1.2-SNAPSHOT [INFO] +- org.slf4j:slf4j-api:jar:1.7.25:compile [INFO] +- org.apache.poi:poi:jar:3.17:compile [INFO] | +- commons-codec:commons-codec:jar:1.10:compile [INFO] | \- org.apache.commons:commons-collections4:jar:4.1:compile [INFO] \- org.apache.poi:poi-ooxml:jar:3.17:compile [INFO] +- org.apache.poi:poi-ooxml-schemas:jar:3.17:compile [INFO] | \- org.apache.xmlbeans:xmlbeans:jar:2.6.0:compile [INFO] | \- stax:stax-api:jar:1.0.1:compile [INFO] \- com.github.virtuald:curvesapi:jar:1.04:compile [INFO] ------------------------------------------------------------------------ [INFO] BUILD SUCCESS [INFO] ------------------------------------------------------------------------ [INFO] Total time: 1.572 s [INFO] Finished at: 2019-04-19T11:24:17+08:00 [INFO] ------------------------------------------------------------------------
mvn:dependency:tree
打印出来的是 maven解决了冲突后的树(解决冲突的策略是:就近原则,即离根近的依赖被采纳)html
$ mvn dependency:tree -Dverbose [WARNING] [WARNING] Some problems were encountered while building the effective settings [WARNING] Unrecognised tag: 'properties' (position: START_TAG seen ...</profile>\n\t <properties>... @85:18) @ C:\Users\qhong\.m2\settings.xml, line 85, column 18 [WARNING] [INFO] Scanning for projects... [INFO] [INFO] -----------------------< com.xuxueli:xxl-excel >------------------------ [INFO] Building xxl-excel 1.1.2-SNAPSHOT [INFO] --------------------------------[ jar ]--------------------------------- [INFO] [INFO] --- maven-dependency-plugin:2.8:tree (default-cli) @ xxl-excel --- [INFO] com.xuxueli:xxl-excel:jar:1.1.2-SNAPSHOT [INFO] +- org.slf4j:slf4j-api:jar:1.7.25:compile [INFO] +- org.apache.poi:poi:jar:3.17:compile [INFO] | +- commons-codec:commons-codec:jar:1.10:compile [INFO] | \- org.apache.commons:commons-collections4:jar:4.1:compile [INFO] \- org.apache.poi:poi-ooxml:jar:3.17:compile [INFO] +- (org.apache.poi:poi:jar:3.17:compile - omitted for duplicate) [INFO] +- org.apache.poi:poi-ooxml-schemas:jar:3.17:compile [INFO] | \- org.apache.xmlbeans:xmlbeans:jar:2.6.0:compile [INFO] | \- stax:stax-api:jar:1.0.1:compile [INFO] \- com.github.virtuald:curvesapi:jar:1.04:compile [INFO] ------------------------------------------------------------------------ [INFO] BUILD SUCCESS [INFO] ------------------------------------------------------------------------ [INFO] Total time: 1.636 s [INFO] Finished at: 2019-04-19T11:13:29+08:00 [INFO] ------------------------------------------------------------------------
经过指定
-Dverbose
参数则能够显示原始的依赖树,让你显式地看出某个包都在哪些枝干上出现了。java
递归依赖的关系列的算是比较清楚了,每行都是一个jar包,根据缩进能够看到依赖的关系。git
只想看依赖树中包含 groupId 为 javax.serlet 的枝干 mvn dependency:tree -Dincludes=javax.servlet 不想看依赖树中包含 groupId 为 javax.serlet 的枝干 mvn dependency:tree -Dexcludes=javax.servlet
参数的格式(pattern)定义以下:github
[groupId]:[artifactId]:[type]:[version]
每一个部分(冒号分割的部分)是支持*
通配符的,若是要指定多个格式则能够用,
分割,如:apache
mvn dependency:tree -Dincludes=javax.servlet,org.apache.*
demo:segmentfault
$ mvn dependency:tree -Dverbose -Dincludes=org.apache.poi [WARNING] [WARNING] Some problems were encountered while building the effective settings [WARNING] Unrecognised tag: 'properties' (position: START_TAG seen ...</profile>\n\t <properties>... @85:18) @ C:\Users\qhong\.m2\settings.xml, line 85, column 18 [WARNING] [INFO] Scanning for projects... [INFO] [INFO] -----------------------< com.xuxueli:xxl-excel >------------------------ [INFO] Building xxl-excel 1.1.2-SNAPSHOT [INFO] --------------------------------[ jar ]--------------------------------- [INFO] [INFO] --- maven-dependency-plugin:2.8:tree (default-cli) @ xxl-excel --- [INFO] com.xuxueli:xxl-excel:jar:1.1.2-SNAPSHOT [INFO] +- org.apache.poi:poi:jar:3.17:compile [INFO] \- org.apache.poi:poi-ooxml:jar:3.17:compile [INFO] +- (org.apache.poi:poi:jar:3.17:compile - omitted for duplicate) [INFO] \- org.apache.poi:poi-ooxml-schemas:jar:3.17:compile [INFO] ------------------------------------------------------------------------ [INFO] BUILD SUCCESS [INFO] ------------------------------------------------------------------------ [INFO] Total time: 1.635 s [INFO] Finished at: 2019-04-19T11:17:21+08:00 [INFO] ------------------------------------------------------------------------
也能够直接查询一个artifactidapi
mvn dependency:tree -Dverbose -Dincludes=:notify-common
mvn dependency:purge-local-repository
默认状况下,插件对全部传递依赖项进行操做。这意味着插件能够在开始清除过程以前下载某些缺乏的依赖项以收集完整的依赖关系树信息。maven
为避免此预下载步骤,能够将插件配置为仅使用“actTranstively”参数对项目的直接依赖性进行操做。测试
mvn dependency:purge-local-repository -DactTransitively=false
actTransitively是否应该对全部传递依赖性起做用。默认值为true。ui
设置为false就仅对项目的直接依赖项进行删除,不进行设置就所有删除,包括依赖包的依赖包。。。
mvn dependency:purge-local-repository -DreResolve=false
reResolve是否从新解析依赖关系(就是删除之后是否从新下载依赖包)
mvn dependency:purge-local-repository -DactTransitively=false -DreResolve=false --fail-at-end
忽略错误( --fail-at-end
)。 对于那些有一些依赖关系混乱的项目,或者依赖于一些内部的仓库(这种状况发生),这样作有时是有用的。
mvn dependency:purge-local-repository -Dinclude=org.slf4j:slf4j-api,org.slf4j:log4j-over-slf4j
手动清除不属于当前项目依赖关系树的特定依赖项
mvn dependency:purge-local-repository -DmanualIncludes=org.apache:apache
通过测试发现,清理本地代码的include,exclude全无效,不会清除本地任何依赖,includes,exculdes也无效,会清除所有本地依赖,不知道咋回事。