如何找出 Maven 包含某个 jar 的原因?

发布于 2024-10-10 05:03:45 字数 314 浏览 0 评论 0原文

我们将 Maven 3 与 IntelliJ 用于我们的 IDE。编译后,我们得到了一堆 spring 2.0 的东西,它们被包含在外部库中。如果我查看 Intellij 中的 Maven 项目依赖项,我没有看到任何人依赖于 spring 2.0,所以我怀疑这是我们所依赖的东西,而它又依赖于它。

我的问题是我将如何追踪这一点?我尝试执行 mvn dependency:tree -Dverbose -Dincludes=spring-aop 甚至 -Dincludes=spring 但从根或子模块目录运行时没有得到任何结果我知道正在使用弹簧。

We're using Maven 3 with IntelliJ for our IDE. After a compile we get a bunch of spring 2.0 stuff being included in the External Libraries. If I look through Maven Projects dependencies in Intellij I don't see anyone with a dependency on spring 2.0 so I suspect it's something we're depending on which depends on it.

My question is how would I track this down? I tried doing a mvn dependency:tree -Dverbose -Dincludes=spring-aop and even -Dincludes=spring but get no results when ran from the root or a sub module directory that I know is using spring.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

蹲墙角沉默 2024-10-17 05:03:45

看起来传递给 -Dincludes 的模式不正确。

Maven 依赖插件 的文档中, -Dincludes 的语法由 StrictPatternIncludesArtifactFilter 定义。来自AbstractStrictPatternArtifactFilter 这是它的子类,

工件模式语法是
形式:

[groupId]:[artifactId]:[type]:[version]

其中每个模式段都是可选的,并且支持完整和
部分 * 通配符。空图案
段被视为隐式
通配符。

例如,org.apache.* 将匹配其组的所有工件
id 以 org.apache. 开头,并且 :::*-SNAPSHOT 将匹配所有快照
文物。

也许您应该运行不带 -Dincludesmvn dependency:tree 并查看它是否显示 spring 2.0 相关依赖项。或者,为 -Dincludes 指定适当的模式。

It looks like the pattern passed to -Dincludes is incorrect.

From the documentation of Maven Dependency Plugin, the syntax of -Dincludes is defined by StrictPatternIncludesArtifactFilter. From the javadoc of AbstractStrictPatternArtifactFilter from which this is subclassed,

The artifact pattern syntax is of the
form:

[groupId]:[artifactId]:[type]:[version]

Where each pattern segment is optional and supports full and
partial * wildcards. An empty pattern
segment is treated as an implicit
wildcard.

For example, org.apache.* would match all artifacts whose group
id started with org.apache., and :::*-SNAPSHOT would match all snapshot
artifacts.

Maybe you should run mvn dependency:tree without -Dincludes and see if it shows up the spring 2.0 related dependency. Alternately, specify the appropriate pattern for -Dincludes.

回眸一笑 2024-10-17 05:03:45

您搜索的格式错误。试试这个:(

mvn dependency:tree -Dverbose -Dincludes=:spring*::

搜索任何带有以 spring 开头的 groupId 的工件)

或者这个:(

mvn dependency:tree -Dverbose -Dincludes=org.springframework

搜索带有 artifactId org.springframework 的任何工件)

The format you are searching for is wrong. Try this:

mvn dependency:tree -Dverbose -Dincludes=:spring*::

(Searches for any artifact with a groupId that starts with spring)

Or this:

mvn dependency:tree -Dverbose -Dincludes=org.springframework

(Searches for any artifact with artifactId org.springframework)

暗恋未遂 2024-10-17 05:03:45

为什么不使用 intellij 并轻松修复它。
打开 pom.xml,右键单击(调用上下文菜单)并选择 UML >显示依赖关系(假设您启用了 UML 插件)。
Idea 将标记所有重复的依赖项,您可以使用 ALT+Enter 组合来排除依赖项。
@参见:
http://blogs.jetbrains.com/idea/2010/05/ maven-依赖关系图/

Why not use intellij and easy fix it.
Open your pom.xml, right-click (invoke context menu) and choose UML > show dependencies (assumin you have UML plugin enabled).
Idea will mark all duplicate dependency and you can use ALT+Enter combo to exclude dependencies.
@see also:
http://blogs.jetbrains.com/idea/2010/05/maven-dependencies-diagram/

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文