当我 运行 maven install 命令时出现 "Could not resolve dependencies" 错误
I got "Could not resolve dependencies" error when I run maven install command
我在 pom.xml 中添加了私有 nexus 存储库 url 以从内部 nexus 存储库安装一些依赖项。
但是 eclipse 仍然在 pom.xml 文件中显示 "Missing artifact error" 条消息
这是我 运行 mvn install 命令
时的命令行错误消息
[ERROR] Failed to execute goal on project diffapi: Could not resolve dependencies for project com.my:diffapi:jar:0.0.1-SNAPSHOT: The following artifacts could not be resolved: 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: Failure to find com.aaa.bbb.poi.jar:poi:jar:5.14.4 in https://repo.maven.apache.org/maven2 was cached in the local repository, resolution will not be reattempted until the update interval of central has elapsed or updates are forced
maven 似乎只能访问 maven central 而不是私有 nexus 存储库
这是我的 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>
您似乎混淆了在使用存储库构建项目后部署项目的存储库,这些存储库用作项目中依赖项的来源。您实际上还没有指定自定义的第 3 方回购协议,因此 Maven 在未能在中央回购协议中找到工件后放弃了。来自 Maven documentation:
Whereas the repositories element specifies in the POM the location and manner in which Maven may download remote artifacts for use by the current project, distributionManagement specifies where (and how) this project will get to a remote repository when it is deployed. The repository elements will be used for snapshot distribution if the snapshotRepository is not defined.
因此,尝试添加一个 <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>
我在 pom.xml 中添加了私有 nexus 存储库 url 以从内部 nexus 存储库安装一些依赖项。
但是 eclipse 仍然在 pom.xml 文件中显示 "Missing artifact error" 条消息
这是我 运行 mvn install 命令
时的命令行错误消息[ERROR] Failed to execute goal on project diffapi: Could not resolve dependencies for project com.my:diffapi:jar:0.0.1-SNAPSHOT: The following artifacts could not be resolved: 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: Failure to find com.aaa.bbb.poi.jar:poi:jar:5.14.4 in https://repo.maven.apache.org/maven2 was cached in the local repository, resolution will not be reattempted until the update interval of central has elapsed or updates are forced
maven 似乎只能访问 maven central 而不是私有 nexus 存储库
这是我的 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>
您似乎混淆了在使用存储库构建项目后部署项目的存储库,这些存储库用作项目中依赖项的来源。您实际上还没有指定自定义的第 3 方回购协议,因此 Maven 在未能在中央回购协议中找到工件后放弃了。来自 Maven documentation:
Whereas the repositories element specifies in the POM the location and manner in which Maven may download remote artifacts for use by the current project, distributionManagement specifies where (and how) this project will get to a remote repository when it is deployed. The repository elements will be used for snapshot distribution if the snapshotRepository is not defined.
因此,尝试添加一个 <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>