<dependencies>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-webmvc</artifactId>
<version>6.0.9</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-aop</artifactId>
<version>5.3.23</version>
</dependency>
</dependencies>
Alt+Shift+M / View > Tool Windows > Maven)。
Dependencies 节点。
-
这里能看到所有依赖树结构。 -
如果某个依赖有冲突,IDEA 通常会用 灰色/红色字体标注出被排除或版本冲突的 jar。

mvn dependency:tree
[INFO] org.example:dependency-test:jar:1.0-SNAPSHOT
[INFO] +- org.springframework:spring-webmvc:jar:6.0.9:compile
[INFO] | +- org.springframework:spring-beans:jar:6.0.9:compile
[INFO] | +- org.springframework:spring-context:jar:6.0.9:compile
[INFO] | +- org.springframework:spring-core:jar:6.0.9:compile
[INFO] | | \- org.springframework:spring-jcl:jar:6.0.9:compile
[INFO] | +- org.springframework:spring-expression:jar:6.0.9:compile
[INFO] | \- org.springframework:spring-web:jar:6.0.9:compile
[INFO] | \- io.micrometer:micrometer-observation:jar:1.10.7:compile
[INFO] | \- io.micrometer:micrometer-commons:jar:1.10.7:compile
[INFO] \- org.springframework:spring-aop:jar:5.3.23:compile
org.springframework:spring-beans:jar:6.0.9:compile用的6.0.0的版本
mvn dependency:tree -Dincludes=org.springframework
Maven Helper 插件(在 IDEA 插件市场搜索)。
Dependency Analyzer 标签页。
-
一键查看依赖树
-
高亮显示冲突 jar 包
-
直接右键选择 Exclude 依赖

groupId + artifactId 但不同版本的依赖。
org.springframework:spring-beans:6.0.9
org.springframework:spring-beans:5.3.23 (omittedforconflict)
spring-beans 有两个版本冲突。
exclusion。
spring-boot-starter 引入了错误的 commons-logging,可以这样写:
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-webmvc</artifactId>
<version>6.0.9</version>
<exclusions>
<exclusion>
<groupId>org.springframework</groupId>
<artifactId>spring-beans</artifactId>
</exclusion>
</exclusions>
</dependency>
dependencyManagement或者如果只是版本不一致,可以在 dependencyManagement 里强制指定版本:
<dependencyManagement>
<dependencies>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-beans</artifactId>
<version>5.3.23</version>
</dependency>
</dependencies>
</dependencyManagement>

-
快速看依赖树 → IDEA 自带依赖树 或 mvn dependency:tree。 -
高效排查冲突 → 装 Maven Helper插件,直观显示冲突。 -
解决冲突 → 用 exclusion排除不需要的包,或在dependencyManagement锁定版本。
往期推荐
再见Navicat、XShell!一款高颜值的数据库、SSH、Docker管理工具!
SpringBoot一行代码搞定请假审批流程,摸鱼时间翻倍!
凌晨两点,我因为 14 寸笔记本的 9 号字体把线上事故从 P0 拖成了 P1
还在手动发包?全网最全的 Jenkins + Maven + Git 自动化部署指南!
别再只会mvn install了!深入拆解Maven插件核心原理
Java + LangChain = 王炸!

