likes
comments
collection
share

Intellij IDEA--根据maven依赖名查找它是哪个pom.xml引入的

作者站长头像
站长
· 阅读数 18

简介

本文介绍Idea如何根据maven依赖名查找它是哪个pom.xml引入的。

有时候会有这样的问题:我们知道项目里用了某个依赖,想知道它是项目里哪个pom.xml引入的,这样可以进行修改版本、更新依赖等操作。

示例

需求:有个分布式项目,想确定订单微服务(order-core)里使用的feign是哪个pom.xml引入的。

1. Idea安装maven helper插件

Intellij IDEA--根据maven依赖名查找它是哪个pom.xml引入的

2.在order-core的pom.xml里查找

打开order-core的pom.xml

Intellij IDEA--根据maven依赖名查找它是哪个pom.xml引入的

点击“Dependencies Analyzer”(依赖分析器)

Intellij IDEA--根据maven依赖名查找它是哪个pom.xml引入的

点击“All Dependencies As List”(列表形式显示依赖)

Intellij IDEA--根据maven依赖名查找它是哪个pom.xml引入的

Intellij IDEA--根据maven依赖名查找它是哪个pom.xml引入的

搜索“feign”,点击“feign-core",在右侧可以看到依赖结构,发现最顶层依赖是”spring-cloud-starter-openfeign“。

Intellij IDEA--根据maven依赖名查找它是哪个pom.xml引入的

点击“spring-cloud-starter-openfeign”

Intellij IDEA--根据maven依赖名查找它是哪个pom.xml引入的

可以看到,本pom.xml(order-core)、account-api、storage-api都引入了 “spring-cloud-starter-openfeign”

3.找本层(order-core)的pom.xml

Intellij IDEA--根据maven依赖名查找它是哪个pom.xml引入的

可以看到,本层没有引入“spring-cloud-starter-openfeign”。

4.找上层的pom.xml

找“account-api”和“storage-api”的pom.xml

Intellij IDEA--根据maven依赖名查找它是哪个pom.xml引入的

Intellij IDEA--根据maven依赖名查找它是哪个pom.xml引入的

可以看到,“account-api”和“storage-api”都没有引入“spring-cloud-starter-openfeign”

5.找上上层的pom.xml

“account-api”和“storage-api”都以此pom.xml为父级:../../../parent/parent-api/pom.xml

Intellij IDEA--根据maven依赖名查找它是哪个pom.xml引入的

OK,找到了。

欢迎关注我的公众号:敲代码的老贾,回复“领取”赠送《Java面试》资料,阿里,腾讯,字节,美团,饿了么等大厂