$ 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也無效,會清除所有本地依賴,不知道咋回事。