Maven 指令 mvn:dependency:tree 查看依赖
2022/4/15 6:14:19
本文主要是介绍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
二、常用参数详解
-
includes
类型:String
描述:显示包含依赖的jar包。
格式:[groupId]:[artifactId]:[type]:[version]
,支持通配符*。例如,org.apache.*
将匹配groupid 以org.apache.
开头的所有内容;:::*-SNAPSHOT
匹配所有jar。 -
excludes
类型:String
描述:显示不包含依赖的jar包。
格式:[groupId]:[artifactId]:[type]:[version]
,支持通配符* -
appendOutput
类型:boolean
描述:是否将输出内容追加到文件或覆盖它。
默认值:false
-
outputEncoding
类型:String
描述:无
默认值:${project.reporting.outputEncoding}
-
outputFile
类型:File
描述:如果指定,此参数将将依赖关系树写入指定的路径,而不是写入控制台。 -
outputType
类型:String
描述:如果指定,此参数将使用指定格式写入依赖关系树。当前支持的格式有:(text
默认)dot
、graphml
和tgf
。这些附加格式可以绘制到图像文件中。
默认值:text
。 -
verbose
类型:boolean
描述:查看冲突和重复的具体情况
默认值:false
。
三、一般常用的命令
-
查看项目依赖:
mvn dependency:analyze
-
查看项目直接和传递依赖:
mvn dependency:tree
-
冲突和重复的具体情况,用verbose参数
mvn dependency:tree -Dverbose
-
查看依赖树中包含某个groupId和artifactId的依赖链(注意-Dincludes后面是等于号)
mvn dependency:tree -Dincludes=com.alibaba:fastjson
-
查看依赖树中包含某个artifactId的依赖链(artifactId前面加上冒号)
mvn dependency:tree -Dincludes=:fastjson
-
查看依赖树中包含某个groupId的依赖链(-Dincludes后面跟上groupId)
mvn dependency:tree -Dincludes=com.alibaba
-
查看maven构建时有效的pom:
mvn help:effective-pom
-
重定向至文本文件
mvn dependency:tree -D outputFile=dependency_tree.txt
mvn dependency:tree -D outputFile=dependency_tree.txt -D outputType=dot
-
查看冲突和重复的具体情况,用verbose参数
mvn dependency:tree -Dverbose
“+-”符号表示该包后面还有其它依赖包,“-”表示该包后面不再依赖其它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)
这篇关于Maven 指令 mvn:dependency:tree 查看依赖的文章就介绍到这儿,希望我们推荐的文章对大家有所帮助,也希望大家多多支持为之网!
- 2024-05-15PingCAP 黄东旭参与 CCF 秀湖会议,共探开源教育未来
- 2024-05-13PingCAP 戴涛:构建面向未来的金融核心系统
- 2024-05-09flutter3.x_macos桌面os实战
- 2024-05-09Rust中的并发性:Sync 和 Send Traits
- 2024-05-08使用Ollama和OpenWebUI在CPU上玩转Meta Llama3-8B
- 2024-05-08完工标准(DoD)与验收条件(AC)究竟有什么不同?
- 2024-05-084万 star 的 NocoDB 在 sealos 上一键起,轻松把数据库编程智能表格
- 2024-05-08Mac 版Stable Diffusion WebUI的安装
- 2024-05-08解锁CodeGeeX智能问答中3项独有的隐藏技能
- 2024-05-08RAG算法优化+新增代码仓库支持,CodeGeeX的@repo功能效果提升