gpt4 book ai didi

maven - mvn 依赖 :tree fails on trivial project

转载 作者:行者123 更新时间:2023-12-04 10:03:49 25 4
gpt4 key购买 nike

我有一个非常复杂的项目(大约 100 个模块),我想在它上面运行 mvn dependency:tree .它失败了,提示它无法解决的依赖关系。该项目否则编译得很好。所以我创建了我能想到的最基本的项目,但它仍然失败并出现同样的错误。显然,要么我必须犯一些非常基本的错误,要么 maven-dependency-plugin 尚未被任何人使用。以下是测试项目的三个 POM:

pom.xml:

<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.example</groupId>
<artifactId>root</artifactId>
<version>1.0.0-SNAPSHOT</version>
<packaging>pom</packaging>
<modules>
<module>foo</module>
<module>bar</module>
</modules>
</project>

富/pom.xml:
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.example</groupId>
<artifactId>foo</artifactId>
<version>1.0.0-SNAPSHOT</version>
<packaging>jar</packaging>
</project>

酒吧/pom.xml:
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.example</groupId>
<artifactId>bar</artifactId>
<version>1.0.0-SNAPSHOT</version>
<packaging>jar</packaging>
<dependencies>
<dependency>
<groupId>com.example</groupId>
<artifactId>foo</artifactId>
<version>1.0.0-SNAPSHOT</version>
</dependency>
</dependencies>
</project>

然后我发出以下命令 mvn dependency:tree在顶级目录中并获得以下输出:
[INFO] Scanning for projects...
[INFO] ------------------------------------------------------------------------
[INFO] Reactor Build Order:
[INFO]
[INFO] foo
[INFO] bar
[INFO] root
[INFO]
[INFO] ------------------------------------------------------------------------
[INFO] Building foo 1.0.0-SNAPSHOT
[INFO] ------------------------------------------------------------------------
[INFO]
[INFO] --- maven-dependency-plugin:2.8:tree (default-cli) @ foo ---
[INFO] com.example:foo:jar:1.0.0-SNAPSHOT
[INFO]
[INFO] ------------------------------------------------------------------------
[INFO] Building bar 1.0.0-SNAPSHOT
[INFO] ------------------------------------------------------------------------
[INFO] ------------------------------------------------------------------------
[INFO] Reactor Summary:
[INFO]
[INFO] foo ................................................ SUCCESS [ 0.756 s]
[INFO] bar ................................................ FAILURE [ 0.011 s]
[INFO] root ............................................... SKIPPED
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 1.065 s
[INFO] Finished at: 2015-03-03T16:19:18+01:00
[INFO] Final Memory: 13M/309M
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal on project bar: Could not resolve dependencies for project com.example:bar:jar:1.0.0-SNAPSHOT: Could not find artifact com.example:foo:jar:1.0.0-SNAPSHOT -> [Help 1]
[ERROR]
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR]
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/DependencyResolutionException
[ERROR]
[ERROR] After correcting the problems, you can resume the build with the command
[ERROR] mvn <goals> -rf :bar

我错过了什么?这不应该工作吗?

最佳答案

我很沮丧为什么它不起作用。
一个简单的依赖分析是行不通的。
官方没有任何指导如何做到这一点。
另一个非常有用的命令也不起作用

mvn dependency:resolve

但是,也许你可以试试这些命令

mvn test-compile dependency:resolve
mvn test-compile dependency:tree

无论如何,它对我有用

2017 年 3 月 13 日更新

我们可以通过跳过编译让它更快
 mvn test-compile dependency:resolve -Dmaven.main.skip=true -Dmaven.test.skip=true
mvn test-compile dependency:tree -Dmaven.main.skip=true -Dmaven.test.skip=true

很遗憾它对我们的项目不起作用,因为我们的项目使用的是 kotlin,也许是 kotlin 的错误没有跳过编译,也许我应该将此错误报告给 jetbrains。

关于maven - mvn 依赖 :tree fails on trivial project,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/28835418/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com