运行maven install命令时出现“无法解析依赖项”错误

时间:2019-07-11 05:02:02

标签: maven pom.xml nexus

我在pom.xml中添加了私有nexus存储库URL,以从内部nexus存储库安装一些依赖项。

但是eclipse仍然在pom.xml文件中显示“缺少人工制品错误”消息

这是我运行mvn install命令时的命令行错误消息

  

[错误]无法在项目diffapi上执行目标:无法解决项目com.my:diffapi:jar:0.0.1-SNAPSHOT的依赖项:无法解决以下工件:com.aaa.bbb.poi。 jar:poi:jar:5.14.4,com.aaa.bbb.poi.jar:poi-skp-search-client-util:jar:5.14.4,com.aaa.bbb.poi.jar:poi-util: jar:5.14.4,com.aaa.bbb.frame:ndds-log:jar:1.4.6,com.aaa.bbb.frame:ndds-util:jar:1.4.6,com.aaa.bbb.frame: ndds-monitor-agent:jar:1.5.0,com.aaa.bbb.frame:ndds-web-utility:jar:1.5.0,com.aaa.bbb.frame:ndds-context:jar:1.5.0:无法在本地存储库中缓存https://repo.maven.apache.org/maven2中的com.aaa.bbb.poi.jar:poi:jar:5.14.4的内容,直到中心的更新间隔过去或强制执行更新后,才会重新尝试解析

似乎maven仅访问maven Central而不是私有关系存储库

这是我的pom.xml

    <?xml version="1.0" encoding="UTF-8"?>
<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>
<parent>
    <groupId>org.springframework.boot</groupId>
    <artifactId>spring-boot-starter-parent</artifactId>
    <version>2.1.6.RELEASE</version>
    <relativePath/> <!-- lookup parent from repository -->
</parent>
<groupId>com.my</groupId>
<artifactId>diffapi</artifactId>
<version>0.0.1-SNAPSHOT</version>
<name>diffapi</name>
<description>diff api server for rmi and rest result</description>

<properties>
    <java.version>1.8</java.version>
    <ndds.frame.version>1.5.0</ndds.frame.version>
</properties>

<dependencies>
    <dependency>
        <groupId>com.aaa.bbb.poi.jar</groupId>
        <artifactId>poi</artifactId>
        <version>5.14.4</version>
    </dependency>
    <dependency>
        <groupId>com.aaa.bbb.poi.jar</groupId>
        <artifactId>poi-skp-search-client-util</artifactId>
        <version>5.14.4</version>
    </dependency>
    <dependency>
        <groupId>com.aaa.bbb.poi.jar</groupId>
        <artifactId>poi-util</artifactId>
        <version>5.14.4</version>
    </dependency>
    <dependency>
        <groupId>com.aaa.bbb.frame</groupId>
        <artifactId>ndds-log</artifactId>
        <version>1.4.6</version>
    </dependency>
    <dependency>
        <groupId>com.aaa.bbb.frame</groupId>
        <artifactId>ndds-util</artifactId>
        <version>1.4.6</version>
    </dependency>
    <dependency>
        <groupId>com.aaa.bbb.frame</groupId>
        <artifactId>ndds-monitor-agent</artifactId>
        <version>${ndds.frame.version}</version>
    </dependency>
    <dependency>
        <groupId>com.aaa.bbb.frame</groupId>
        <artifactId>ndds-web-utility</artifactId>
        <version>${ndds.frame.version}</version>
    </dependency>
    <dependency>
        <groupId>com.aaa.bbb.frame</groupId>
        <artifactId>ndds-context</artifactId>
        <version>${ndds.frame.version}</version>
    </dependency>
<distributionManagement>
    <repository>
        <id>AAA-releases</id>
        <name>AAA-releases</name>
        <url>http://IP:PORT/nexus/content/repositories/AAA-releases/</url>
    </repository>
    <snapshotRepository>
        <id>AAA-snapshots</id>
        <name>AAA-snapshots</name>
        <url>http://IP:PORT/nexus/content/repositories/AAA-snapshots</url>
    </snapshotRepository>
</distributionManagement>
</project>

1 个答案:

答案 0 :(得分:0)

您似乎对使用版本库作为项目中依赖项源的版本库进行构建后将部署项目的版本库感到困惑。您实际上尚未指定自定义的第三方存储库,因此在未能在中央存储库中找到工件后,Maven放弃了。来自Maven documentation

  

repositories元素在POM中指定了Maven下载远程工件以供当前项目使用的位置和方式,而distributionManagement指定了该项目在部署时将在何处(以及如何)到达远程存储库。如果未定义snapshotRepository,则将使用存储库元素进行快照分发。

因此,请尝试添加一个<repositories>元素,其中包含您希望构建中的自定义JAR可用的额外存储库:

<project>
    ...
    <distributionManagement>
        <repository>
            <id>AAA-releases</id>
            <name>AAA-releases</name>
            <url>http://IP:PORT/nexus/content/repositories/AAA-releases/</url>
        </repository>
        <snapshotRepository>
            <id>AAA-snapshots</id>
            <name>AAA-snapshots</name>
            <url>http://IP:PORT/nexus/content/repositories/AAA-snapshots</url>
        </snapshotRepository>
    </distributionManagement>
    <repositories>
        <!-- fill in with the actual details of your repo here -->
        <repository>
            <id>REPO ID</id>
            <name>REPO NAME</name>
            <url>YOUR URL GOES HERE</url>
        </repository>
    </repositories>
</project>