Maven依赖树和pom依赖 [英] Maven dependency tree and pom dependencies

查看:438
本文介绍了Maven依赖树和pom依赖的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想知道以下jar的所有传递依赖项:

I would like to know all transitive dependencies of the following jar:

<dependency>
    <groupId>org.codehaus.mojo</groupId>
    <artifactId>xmlbeans-maven-plugin</artifactId>
    <version>2.3.3</version>
</dependency>

将经典命令移至项目的pom.xml中,以定义该依赖项并输入:

Moving a classic command to the pom.xml of the project's defining that dependency and inputting:

mvn依赖项:树

mvn dependency:tree

将显示:

+- org.codehaus.mojo:xmlbeans-maven-plugin:jar:2.3.3:compile
|  +- xml-resolver:xml-resolver:jar:1.2:compile
|  +- org.apache.maven:maven-model:jar:2.0.6:compile
|  +- org.apache.maven:maven-artifact:jar:2.0.6:compile
|  +- org.apache.maven:maven-project:jar:2.0.6:compile
|  |  +- org.apache.maven:maven-settings:jar:2.0.6:compile
|  |  +- org.apache.maven:maven-profile:jar:2.0.6:compile
|  |  +- org.apache.maven:maven-artifact-manager:jar:2.0.6:compile
|  |  |  +- org.apache.maven:maven-repository-metadata:jar:2.0.6:compile
|  |  |  \- org.apache.maven.wagon:wagon-provider-api:jar:1.0-beta-2:compile
|  |  +- org.apache.maven:maven-plugin-registry:jar:2.0.6:compile
|  |  \- org.codehaus.plexus:plexus-container-default:jar:1.0-alpha-9-stable-1:compile
|  |     +- junit:junit:jar:3.8.1:compile
|  |     \- classworlds:classworlds:jar:1.1-alpha-2:compile
|  +- org.apache.maven:maven-plugin-api:jar:2.0.6:compile
|  +- org.apache.xmlbeans:xmlbeans:jar:2.4.0:compile
|  |  \- stax:stax-api:jar:1.0.1:compile
|  \- org.codehaus.plexus:plexus-utils:jar:1.5.6:compile

我没看到父母亲:

  <groupId>org.codehaus.mojo</groupId>
  <artifactId>mojo-parent</artifactId>
  <version>21</version>
  <packaging>pom</packaging>

乍看之下,似乎mvn命令可以显示不是pom类型的依赖项.

At first glance it seems that the mvn command can show the dependencies which are not pom type.

有没有一种方法可以精确显示保持jar存活所需的每个文件?

Is there a way to show exactly every single file needed to keep a jar alive?

谢谢!

推荐答案

实际上,很难显示保持罐子存活"所需的文件.您的项目可能具有一些隐式依赖关系.

Actually it's hard to show files needed to 'keep a jar alive'. Your project can have some implicit dependencies.

您可以运行mvn dependency:analyze,它应该向您显示未使用的依赖项. 但是您已经意识到可以自由删除其中的哪一个. http://maven.apache.org/plugins/maven-dependency -plugin/analyze-mojo.html

You can run mvn dependency:analyze, it should show you unused dependencies. But you have realize which of them you can freely remove. http://maven.apache.org/plugins/maven-dependency-plugin/analyze-mojo.html

我也可以建议您,如果您不希望传递继承有任何意外,请使用maven强制执行器.您可以禁止所有未声明的传递依赖项. http://maven.apache.org/enforcer/enforcer-rules/banTransitiveDependencies.html

I can also recommend if you don't want any surprises with transitive dependencies - use maven enforcer. You can ban all undeclared transitive dependencies. http://maven.apache.org/enforcer/enforcer-rules/banTransitiveDependencies.html

这篇关于Maven依赖树和pom依赖的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆