dependency:tree
可用于查看给定项目的依赖关系树。但我需要的是查看第 3 方工件的依赖关系树。
我想我可以创建一个空项目,但我正在寻找更简单的东西(我需要为几个工件执行此操作)。
最佳答案
1) 使用maven dependency plugin
仅使用 pom.xml
创建一个简单项目。添加您的依赖项并运行:
mvn dependency:tree
(多模块 Maven 项目版本:mvn 编译依赖项:tree
)
不幸的是dependency mojo必须使用 pom.xml
否则您会收到以下错误:
Cannot execute mojo: tree. It requires a project with an existing
pom.xml
, but the build is not using one.
2) 在 Maven 中央存储库中查找工件的 pom.xml
依赖关系在工件的 pom.xml
中描述。使用 Maven 基础设施找到它。
转到https://search.maven.org/并输入您的 groupId
和 artifactId
。
或者您可以访问https://repo1.maven.org/maven2/首先使用插件groupId
进行导航,然后使用artifactId
,最后使用其版本。
例如参见org.springframework:spring-core
3) 对您的工件使用 Maven 依赖插件
依赖项工件的一部分是 pom.xml
。这指定了它的依赖性。你可以在这个pom上执行mvn dependency:tree
。
关于maven-2 - 如何获取工件的依赖树?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/3342908/