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

时间:2020-08-24 17:33:12

标签: java maven

我克隆了一个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”时,可以在我的浏览器中对其进行访问。

经过一番搜索,我将settings.xml文件放在.m2文件夹中,如下所示:

<?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中,为什么我仍然遇到骆驼错误?谢谢

3 个答案:

答案 0 :(得分:1)

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

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

在不了解有关系统的更多详细信息的情况下,很难提供更准确的答案。

This answer提供了可能的解决方法。

答案 1 :(得分:0)

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

根据{{​​3}}的

-U

强制检查丢失的版本和远程上更新的快照 仓库

或尝试删除本地存储库文件夹。有时在出现网络问题时会变得混乱... 您可以在.m2文件夹中找到本地回购文件夹(在Windows上:C:\ Users <您的用户名> .m2)

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

答案 2 :(得分:0)

好的...让它正常工作。

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

以某种方式,我的公司(一家金融机构)拥有一个根CA证书,该证书覆盖了所有其他根CA证书,这意味着,当我打开任何网站(例如stackoverflow)时,证书路径始终显示如下:

enter image description here

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

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

相关问题