Maven如何忽略工件描述符?

有没有办法指示 Maven 不为某些依赖项寻找工件描述符?我正在努力解决这个问题:


[ERROR] Failed to execute goal on project zws-consumer: Could not resolve dependencies for project com.etech.zws:zws-consumer:jar:2.9.28.RC1-SNAPSHOT: Failed to collect dependencies at com.ptv:xlocate-cxf-client:jar:1.20.1.3: Failed to read artifact descriptor for com.ptv:xlocate-cxf-client:jar:1.20.1.3: Could not find artifact com.ptvag.xserver.build:xserver-parent:pom:1.20.1.0 in artifactory-etech-releases (https://artifactory.etech.delivery/artifactory/etech/releases/) -> [Help 1]

org.apache.maven.lifecycle.LifecycleExecutionException: Failed to execute goal on project zws-consumer: Could not resolve dependencies for project com.etech.zws:zws-consumer:jar:2.9.28.RC1-SNAPSHOT: Failed to collect dependencies at com.ptv:xlocate-cxf-client:jar:1.20.1.3

    at org.apache.maven.lifecycle.internal.LifecycleDependencyResolver.getDependencies (LifecycleDependencyResolver.java:269)

...

所以问题似乎很清楚:


Could not find artifact com.ptvag.xserver.build:xserver-parent:pom:1.20.1.0 in artifactory-etech-releases (https://artifactory.etech.delivery/artifactory/etech/releases/)

问题是当我查看存储库https://artifactory.etech.delivery/artifactory/etech/releases/时,没有任何具有此名称的依赖项,com.ptvag.xserver.build:xserver-parent但所有其他依赖项都存在。


由于它只是关于工件描述,有没有办法告诉 Maven 忽略它。具有该描述的所有依赖项都在我的文件中,.m2但由于此错误,命令mvn clean install失败。


构建在 2 天前通过,但我正在尝试将项目从 jdk8 迁移到 11,并且我从 1 天开始就面临这个问题。


相关的依赖是:


    <dependency>

        <groupId>com.ptv</groupId>

        <artifactId>xlocate-cxf-client</artifactId>

        <version>1.20.1.3</version>

    </dependency>

    <dependency>

        <groupId>com.ptv</groupId>

        <artifactId>xroute-cxf-client</artifactId>

        <version>1.20.1.3</version>

    </dependency>

    <dependency>

        <groupId>com.ptv</groupId>

        <artifactId>xtour-cxf-client</artifactId>

        <version>1.20.1.3</version>

    </dependency>

如您所见groupId,这些依赖项是com.ptv,但例外是 about com.ptvag。我有点困惑,因为在存储库中没有com.ptvaggroupId。


慕码人8056858
浏览 90回答 2
2回答

ibeautiful

您可能缺少一个依赖项的父 pom。如果没有这个父 pom,就不可能构建所有传递依赖的树(父 pom 可能包含依赖项或 dependencyManagement 条目)。所以构建不起作用。工件com.ptv:xlocate-cxf-client:jar:1.20.1.3是项目的(传递)依赖项。看看那里,如果描述的 POM 是这个项目的父级。如果是这样,您需要它来构建。

精慕HU

您可以像这样排除依赖项:&nbsp; &nbsp; <project>&nbsp; &nbsp; &nbsp; ...&nbsp; &nbsp; &nbsp; <dependencies>&nbsp; &nbsp; &nbsp; &nbsp; <dependency>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <groupId>com.etech.zws</groupId>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <artifactId>zws-consumer</artifactId>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <exclusions>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <exclusion>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <groupId>com.ptvag.xserver.build</groupId>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <artifactId>xserver-parent</artifactId>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </exclusion>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; </exclusions>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; </dependency>&nbsp; &nbsp; &nbsp; </dependencies>&nbsp; &nbsp; </project>但是,如果 maven 试图解决依赖关系,那么构建/项目的某些部分很可能需要它。你应该以某种方式得到com.ptvag.xserver.build:xserver-parent:pom:1.20.1.0. 如果它不在您的存储库中,您可以手动安装它,mvn install如果您有 pom.xml
打开App,查看更多内容
随时随地看视频慕课网APP

相关分类

Java