猿问

从 mvn dependency:resolve 中排除某些依赖项

在我pom.xml的中com.test:Service:1.0,我依赖于一些本地 jar:com.test:Parser:1.0

我想解决除它之外的所有依赖项,因为我手动将其安装到本地 Maven。解决命令:

mvn -B dependency:resolve -DincludeParents=true

但它失败了:

[错误] 无法在项目服务上执行目标:无法解析项目 com.test:Service:jar:1.0 的依赖项:无法在中心找到工件 com.test:Parser:jar:1.0 ( https://repo.maven .apache.org/maven2

然后我尝试添加选项

-DexcludeGroupIds=com.test -DexcludeArtifactIds=Parser

但我仍然遇到同样的错误。我是否滥用了这些选项?

参考:http://maven.apache.org/plugins/maven-dependency-plugin/resolve-mojo.html


子衿沉夜
浏览 398回答 2
2回答

LEATH

我使用的是 3.8.6,看起来脱机可以与排除*一起使用,但解析不能:mvn dependency:go-offline -DexcludeGroupIds=com.test根据: https: //maven.apache.org/plugins/maven-dependency-plugin/index.htmldependency:go-offline告诉 Maven 解决该项目所依赖的所有内容(依赖项、插件、报告),为离线做好准备。dependency:resolve告诉 Maven 解析所有依赖项并显示版本。

慕尼黑8549860

这似乎只是一个错误。看https://issues.apache.org/jira/browse/MDEP-568https://github.com/apache/maven-dependency-plugin/pull/2正如上述线程中建议的,解决方案是使用不同的库: https:&nbsp;//github.com/qaware/go-offline-maven-plugin在您pom.xml添加插件中:&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <plugin>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <groupId>de.qaware.maven</groupId>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <artifactId>go-offline-maven-plugin</artifactId>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <version>1.2.1</version>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <configuration>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <dynamicDependencies>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </dynamicDependencies>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </configuration>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </plugin>mvn de.qaware.maven:go-offline-maven-plugin:resolve-dependencies然后使用带有所需选项的命令。
随时随地看视频慕课网APP

相关分类

Java
我要回答