其他分享
首页 > 其他分享> > Maven 指令 mvn:dependency:tree 查看依赖

Maven 指令 mvn:dependency:tree 查看依赖

作者:互联网

一、指令指导文档:

https://maven.apache.org/plugins/maven-dependency-plugin/tree-mojo.html
https://maven.apache.org/plugins/maven-dependency-plugin/examples/filtering-the-dependency-tree.html

二、常用参数详解

三、一般常用的命令

“+-”符号表示该包后面还有其它依赖包,“-”表示该包后面不再依赖其它jar包。每个层级结尾处用 - 标记

以下面springboot项目为例,运行上述命令显示的结果:

https://gitee.com/tiankong0310/springboot-weixin-alipay?_from=gitee_search

执行mvn dependency:tree后的依赖(仅展示部分):

[INFO] --- maven-dependency-plugin:3.0.2:tree (default-cli) @ springboot-weixin-alipay ---
[INFO] com.fengdu:springboot-weixin-alipay:war:0.0.1-SNAPSHOT
[INFO] +- com.github.pagehelper:pagehelper-spring-boot-starter:jar:1.2.5:compile
[INFO] |  +- org.mybatis.spring.boot:mybatis-spring-boot-starter:jar:1.3.2:compile
[INFO] |  |  +- org.springframework.boot:spring-boot-starter-jdbc:jar:2.0.3.RELEASE:compile
[INFO] |  |  |  +- com.zaxxer:HikariCP:jar:2.7.9:compile
[INFO] |  |  |  \- org.springframework:spring-jdbc:jar:5.0.7.RELEASE:compile
[INFO] |  |  |     \- org.springframework:spring-tx:jar:5.0.7.RELEASE:compile
[INFO] |  |  +- org.mybatis.spring.boot:mybatis-spring-boot-autoconfigure:jar:1.3.2:compile
[INFO] |  |  +- org.mybatis:mybatis:jar:3.4.6:compile
[INFO] |  |  \- org.mybatis:mybatis-spring:jar:1.3.2:compile
[INFO] |  +- com.github.pagehelper:pagehelper-spring-boot-autoconfigure:jar:1.2.5:compile
[INFO] |  \- com.github.pagehelper:pagehelper:jar:5.1.4:compile
[INFO] |     \- com.github.jsqlparser:jsqlparser:jar:1.0:compile
[INFO] +- com.alibaba:druid-spring-boot-starter:jar:1.1.9:compile
[INFO] |  +- com.alibaba:druid:jar:1.1.9:compile
[INFO] |  +- org.slf4j:slf4j-api:jar:1.7.25:compile
[INFO] |  \- org.springframework.boot:spring-boot-autoconfigure:jar:2.0.3.RELEASE:compile

执行mvn dependency:tree -Dincludes=com.alibaba:后的依赖树:

[INFO] --- maven-dependency-plugin:3.0.2:tree (default-cli) @ springboot-weixin-alipay ---
[INFO] com.fengdu:springboot-weixin-alipay:war:0.0.1-SNAPSHOT
[INFO] \- com.alibaba:druid-spring-boot-starter:jar:1.1.9:compile
[INFO]    \- com.alibaba:druid:jar:1.1.9:compile

执行mvn dependency:tree -Dverbose后的依赖树,可以看到依赖是否存在版本冲突。由于示例代码没有冲突,所以截取了其他项目扫描的结果:

[INFO] --- maven-dependency-plugin:2.8:tree (default-cli) @ esshop ---
[INFO] esshop:esshop:war:0.0.1-SNAPSHOT
[INFO] +- commons-collections:commons-collections:jar:3.2.1:compile
[INFO] +- org.hibernate:hibernate:jar:3.2.2.ga:compile
[INFO] |  \- (commons-collections:commons-collections:jar:2.1.1:compile - omitted for conflict with 3.2.1)
[INFO] +- org.hibernate:hibernate-annotations:jar:3.4.0.GA:compile
[INFO] |  \- org.hibernate:hibernate-core:jar:3.3.0.SP1:compile
[INFO] |     \- (commons-collections:commons-collections:jar:3.1:compile - omitted for conflict with 3.2.1)
[INFO] +- org.springframework.security:spring-security-core:jar:2.0.4:compile
[INFO] |  \- (commons-collections:commons-collections:jar:3.2:compile - omitted for conflict with 3.2.1)
[INFO] +- org.apache.velocity:velocity:jar:1.5:compile
[INFO] |  \- (commons-collections:commons-collections:jar:3.1:compile - omitted for conflict with 3.2.1)
[INFO] \- net.sf.json-lib:json-lib:jar:jdk15:2.4:compile
[INFO]    \- (commons-collections:commons-collections:jar:3.2.1:compile - omitted for duplicate)

标签:INFO,compile,jar,tree,Maven,dependency,org
来源: https://www.cnblogs.com/cavan2021/p/16070267.html