$ 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解决?了冲突后的树(解决冲突的策略是:就近原则,即离根近的依赖被采纳)
$ 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
参数则可以显示原始的依赖树,让你显式地看出某个包都在哪些枝干上出现了。
递归依赖的关系列的算是比较清楚了,每行都是一个jar包,根据缩进可以看到依赖的关系。
只想看依赖树中包含 groupId 为 javax.serlet 的枝干
mvn dependency:tree -Dincludes=javax.servlet
不想看依赖树中包含 groupId 为 javax.serlet 的枝干
mvn dependency:tree -Dexcludes=javax.servlet
参数的格式(pattern)定义如下:
[groupId]:[artifactId]:[type]:[version]
每个部分(冒号分割的部分)是支持*
通配符的,如果要指定多个格式则可以用,
分割,如:
mvn dependency:tree -Dincludes=javax.servlet,org.apache.*
demo:
$ 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] ------------------------------------------------------------------------
也可以直接查询一个artifactid
mvn dependency:tree -Dverbose -Dincludes=:notify-common
mvn dependency:purge-local-repository
默认情况下,插件对所有传递依赖项进行操作。这意味着插件可以在开始清除过程之前下载某些缺少的依赖项以收集完整的依赖关系树信息。
为避免此预下载步骤,可以将插件配置为仅使用“actTranstively”参数对项目的直接依赖性进行操作。
mvn dependency:purge-local-repository -DactTransitively=false
actTransitively是否应该对所有传递依赖性起作用。默认值为true。
设置为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也无效,会清除全部本地依赖,不知道咋回事。
用dependency:tree查看maven引入jar包的传递依赖
Apache Maven Dependency Plugin
原文:https://www.cnblogs.com/hongdada/p/10737618.html