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

时间:2019-10-24 17:51:29

标签: java maven pom.xml maven-dependency-plugin

pom.xml的{​​{1}}中,我对某个本地jar有依赖性:com.test:Service:1.0

我想解决所有依赖关系,因为它是手动安装到本地Maven的。解决命令:

com.test:Parser:1.0

但是失败了:

  

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

然后我尝试添加选项

mvn -B dependency:resolve -DincludeParents=true

,但仍然出现相同的错误。我在滥用选项吗?

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

1 个答案:

答案 0 :(得分:0)

这似乎只是一个错误。见

https://issues.apache.org/jira/browse/MDEP-568

https://github.com/apache/maven-dependency-plugin/pull/2

上述线程中提出的解决方案是使用不同的库:https://github.com/qaware/go-offline-maven-plugin

在您的pom.xml中添加插件:

            <plugin>
                <groupId>de.qaware.maven</groupId>
                <artifactId>go-offline-maven-plugin</artifactId>
                <version>1.2.1</version>
                <configuration>
                    <dynamicDependencies>
                    </dynamicDependencies>
                </configuration>
            </plugin>

然后使用命令mvn de.qaware.maven:go-offline-maven-plugin:resolve-dependencies和必需的选项。