繁体   English   中英

Maven:无法读取工件描述符错误

[英]Maven: Failed to read artifact descriptor error

我克隆了一个 JAVA 存储库,当我尝试使用“mvn install”构建它时,出现以下错误

Could not transfer artifact org.springframework.boot:spring-boot-starter-parent:pom:2.3.2.RELEASE from/to central (https://repo.maven.apache.org/maven2): Transfer failed for https://repo.maven.apache.org/maven2/org/springframework/boot/spring-boot-starter-parent/2.3.2.RELEASE/spring-boot-starter-parent-2.3.2.RELEASE.pom and 'parent.relativePath' points at no local POM @ line 6, column 13: PKIX path building failed: sun.security.provider.certpath.SunCertPathBuilderException: unable to find valid certification path to requested target -> [Help 2]

当我在 Chrome 中打开它时,可以在我的浏览器中访问存储库“https://repo.maven.apache.org/maven2”。

经过一番谷歌搜索后,我在 .m2 文件夹中放置了一个 settings.xml 文件,如下所示

<?xml version="1.0" encoding="UTF-8"?>
<settings>
  <activeProfiles>
    <!--make the profile active all the time -->
    <activeProfile>securecentral</activeProfile>
  </activeProfiles>
  <profiles>
    <profile>
      <id>securecentral</id>
      <!--Override the repository (and pluginRepository) "central" from the
         Maven Super POM -->    
      <repositories>
        <repository>
          <id>central</id>
          <url>https://repo1.maven.org/maven2</url>
          <releases>
            <enabled>true</enabled>
          </releases>
        </repository>
      </repositories>
      <pluginRepositories>
        <pluginRepository>
          <id>central</id>
          <url>https://repo1.maven.org/maven2</url>
          <releases>
            <enabled>true</enabled>
          </releases>
        </pluginRepository>
      </pluginRepositories>
    </profile>
  </profiles>
</settings>

现在,当我运行“mvn install”时,spring-boot 的错误消失了。 但我现在面临这个错误:

Failed to read artifact descriptor for org.apache.camel.springboot:camel-salesforce-starter:jar:3.4.2: Could not transfer artifact io.dropwizard.metrics:metrics-bom:pom:4.1.9 from/to central (https://repo.maven.apache.org/maven2): Transfer failed for https://repo.maven.apache.org/maven2/io/dropwizard/metrics/metrics-bom/4.1.9/metrics-bom-4.1.9.pom: PKIX path building failed: sun.security.provider.certpath.SunCertPathBuilderException: unable to find valid certification path to requested target -> [Help 1]

我的问题是,为什么我需要在 settings.xml 中手动添加 和 以及为什么我仍然收到骆驼的错误? 谢谢

PKIX 路径构建失败:sun.security.provider.certpath.SunCertPathBuilderException:无法找到请求目标的有效认证路径

几乎可以肯定您系统上的根 CA 证书已过时。 尝试更新您的 JDK 安装。 请注意,您的浏览器使用的 CA 证书可能与 JRE/JDK 使用的不同。

如果不了解有关您系统的更多详细信息,就很难提供更准确的答案。

此答案提供了可能的解决方法。

您可以尝试运行mvn -U clean install

-U根据Maven CLI 选项用于

强制检查远程存储库上缺少的版本和更新的快照

或尝试删除本地存储库文件夹。 有时在遇到网络问题时它会变得一团糟……您可以在 .m2 文件夹中找到本地 repo 文件夹(在 Windows 上:C:\\Users<your_username>.m2)

您可以删除整个存储库文件夹或其中的一部分。 之后只需运行mvn clean install

好的...得到它的工作。

@rkosegi 的回答让我走上了正确的道路。 我的浏览器使用的根 CA 证书与 jdk 使用的不同。 这就是为什么我可以在浏览器中查看 repo 没有错误,但 maven 无法访问 repo。

不知何故,我的公司(一家金融机构)有一个根 CA 证书覆盖了所有其他根 CA 证书,这意味着,当我打开任何网站(例如 stackoverflow)时,证书路径总是显示如下:

在此处输入图片说明

我不是系统管理员,不确定这是如何完成的,但无论如何,我需要做的就是将根 CA 证书另存为 *.CER 文件并将其添加到 jdk 的 cacert 文件夹中。

之后,命令“mvn clean install”运行完成,没有错误

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM