[spring-projects/spring-boot]项目构建错误: spring-boot-starter-parent:pom:2.0.6.RELEASE 的不可解析父 POM

2018-10-26 661 views
3

我在 Spring Tool Suite 3.9.6.RELEASE 中创建了一个演示项目。

在 中POM.xml,我收到以下错误:

Project build error: Non-resolvable parent POM for com.example:demo:0.0.1-SNAPSHOT: Failure to transfer org.springframework.boot:spring-boot-starter-parent:pom:2.0.6.RELEASE from 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. Original error: Could not transfer artifact org.springframework.boot:spring-boot-starter-parent:pom:2.0.6.RELEASE from/to central (https://repo.maven.apache.org/maven2): connect timed out and 'parent.relativePath' points at wrong local POM

当我运行 Maven clean 时,它会生成构建错误:

The build could not read 1 project -> [Help 1]
[ERROR]   
[ERROR]   The project com.example:demo:0.0.1-SNAPSHOT (C:\ws\demo\pom.xml) has 1 error
[ERROR]     Non-resolvable parent POM for com.example:demo:0.0.1-SNAPSHOT: Could not transfer artifact org.springframework.boot:spring-boot-starter-parent:pom:2.0.6.RELEASE from/to central (https://repo.maven.apache.org/maven2): connect timed out and 'parent.relativePath' points at no local POM @ line 14, column 10 -> [Help 2]
[ERROR] 
<?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>

    <groupId>com.example</groupId>
    <artifactId>demo</artifactId>
    <version>0.0.1-SNAPSHOT</version>
    <packaging>war</packaging>

    <name>demo</name>
    <description>Demo project for Spring Boot</description>

    <parent>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-parent</artifactId>
        <version>2.0.6.RELEASE</version>
        <relativePath>../pom.xml</relativePath> <!-- lookup parent from repository -->
    </parent>

    <properties>
        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
        <project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
        <java.version>1.8</java.version>
    </properties>

    <dependencies>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-web</artifactId>
        </dependency>

        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-tomcat</artifactId>
            <scope>provided</scope>
        </dependency>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-test</artifactId>
            <scope>test</scope>
        </dependency>
    </dependencies>

    <build>
        <plugins>
            <plugin>
                <groupId>org.springframework.boot</groupId>
                <artifactId>spring-boot-maven-plugin</artifactId>
            </plugin>
        </plugins>
    </build>

</project>

回答

8

Spring Boot 2.0.6.RELEASE可在 Maven Central 上使用

这看起来像是设置问题,也许是网络问题?

另外,我认为你的 POM 应该是这样的:

<relativePath/> <!-- lookup parent from repository -->

您可以尝试在 start.spring.io 上创建一个新项目,然后运行./mvnw dependency:purge-local-repository./mvnw spring-boot:run

7

原始日志显示尝试连接https://repo.maven.apache.org/maven2超时。这可能是暂时的网络问题。我将关闭这一问题,因为我们在 Spring Boot 中无能为力来解决 Maven 与 Maven Central 建立网络连接的问题。

6

大家好,

我在最新版本的 Spring-boot 中观察到了这个问题,就像当您使用最新版本的 spring 初始化程序启动时,然后这个错误出现在旧版本(如 2.1.11 或 2.1.13)中,我们很好。

我怀疑最新版本的 pom.xml 文件存在一些问题。

谢谢

6

@bclozel我尝试了以下步骤:

  • 我尝试进行 Maven 强制更新,但没有成功。
  • 我也尝试了这两个命令,但每个命令都抛出相同的错误:

[信息]下载:https://repo.spring.io/milestone/org/springframework/boot/spring-boot-starter-parent/2.3.0.M4/spring-boot-starter-parent-2.3.0.M4 .pom [错误] [错误] 处理 POM 时遇到一些问题: [致命] com.raghav:cityproject:0.0.1-SNAPSHOT 的不可解析父 POM:无法传输工件 org.springframework.boot:spring- boot-starter-parent:pom:2.3.0.M4 从/到 spring-milestones ( https://repo.spring.io/milestone ): sun.security.validator.ValidatorException: PKIX 路径构建失败: sun.security。 provider.certpath.SunCertPathBuilderException:无法找到请求目标的有效证书路径,并且“parent.relativePath”指向没有本地 POM @ 第 5 行,第 10 列

看起来 repo pom 在某些时候无法解析,因此几乎没有下载依赖项,日志中 POM 的路径: https://repo.spring.io/milestone/org/springframework/boot/spring-boot-starter-父/2.3.0.M4/spring-boot-starter-parent-2.3.0.M4.pom

我怀疑春季回购是否存在一些证书问题或其他问题。

  • 这是我的依赖

捕获

7

@Raghav-Github1989,我们对此无能为力,因为这是您正在使用的代理或您在 java 运行时中安装的任何证书的问题。

2.3.0.M4对我来说解决得很好。

7

问题仍然存在,没有人处理它

6

@krispant 这个问题是关于临时网络问题。我们无能为力来处理它,因为它是由我们无法控制的基础设施造成的。如果您的本地网络出现问题,您也许可以自行解决。

9

我可以通过 url 访问 Maven 存储库,所以我不认为网络有任何问题,但是当我执行 Maven clean 或从 Eclipse 构建时,我遇到了这个问题,我是否缺少任何配置..它简单的 hello world spring boot由 spring 初始化程序创建的应用程序

2

@krispant 这可能是你的 Maven 安装的网络配置与你的浏览器的网络配置不同的问题。例如,您的网络可能需要使用在浏览器中配置的代理,而不是在 Maven 中配置的代理。不幸的是,这些都是我们无法为您解决的,因为它们超出了我们的控制范围。

如果您仍然遇到问题,我建议您在 Stack Overflow 上提出一个问题,其中详细描述了您的 Maven 配置并包括失败的整个输出。

4

@wilkinsona 下面一位朋友有什么想法吗? pom.xml 与此链中提到的几乎相同。

步骤 3/37:添加 ./pom.xml /application/pom.xml ---> 0b22d850663f 步骤 4/37:运行 mvn clean install -Dmaven.wagon.http.ssl.insecure=true -Dmaven.wagon.http。 ssl.allowall=true -DskipTests -f application/pom.xml ---> 在 3d85e61244b4 中运行 [‌INFO‌扫描项目...‌从 tfs-gsk-com-platformproduct-rdip-artifacts-test 下载:https://tfs .gsk.com/tfs/PlatformProduct/_packaging/rdip-artifacts-test/maven/v1/org/springframework/boot/spring-boot-starter-parent/1.5.3.RELEASE/spring-boot-starter-parent-1.5 .3.RELEASE.pom 从中心下载:https://repo.maven.apache.org/maven2/org/springframework/boot/spring-boot-starter-parent/1.5.3.RELEASE/spring-boot-starter- parent-1.5.3.RELEASE.pom [‌ERROR‌[ERROR] 处理 POM 时遇到一些问题:‌[FATAL] com.gsk:data-ws-Rancher-Test:0.10.0 的不可解析父 POM:可以不将工件 org.springframework.boot:spring-boot-starter-parent:pom:1.5.3.RELEASE 从/到 tfs-gsk-com-platformproduct-rdip-artifacts-test ( https://tfs.gsk.com /tfs/PlatformProduct/_packaging/rdip-artifacts-test/maven/v1 ): 未经授权,'parent.relativePath' 指向无本地 POM @ 第 11 行,第 13 列 @ [‌错误‌构建无法读取 1 个项目 -> ‌[帮助 1]‌ [‌ERROR‌‌ ‌ [‌ERROR‌ 项目 com.gsk:data-ws-Rancher-Test:0.10.0 (/application/pom.xml) 有 1 个错误‌ [‌ERROR‌ com.gsk:data 的不可解析的父 POM -ws-Rancher-Test:0.10.0:无法从 tfs-gsk-com-platformproduct-rdip-artifacts 传输工件 org.springframework.boot:spring-boot-starter-parent:pom:1.5.3.RELEASE -test (https://tfs.gsk.com/tfs/PlatformProduct/_packaging/rdip-artifacts-test/maven/v1):未授权且“parent.relativePath”指向无本地 POM @ 第 11 行第 13 列 - > ‌[帮助 2]‌ [‌错误‌[‌错误‌要查看错误的完整堆栈跟踪,请使用 ‌-e‌witch 重新运行 Maven。‌[‌错误‌使用 ‌-X‌witch 重新运行 Maven 以启用完整的调试日志记录。‌[‌错误‌‌ [‌ERROR‌有关错误和可能的解决方案的更多信息,请阅读以下文章:‌[‌ERROR‌[Help 1]‌ttp://cwiki.apache.org/confluence/display/MAVEN/ProjectBuildingException‌[‌ERROR‌[Help 2]‌ttp:/ /cwiki.apache.org/confluence/display/MAVEN/UnresolvableModelException‌ 命令 '/bin/sh -c mvn clean install -Dmaven.wagon.http.ssl.insecure=true -Dmaven.wagon.http.ssl.allowall=true -DskipTests -f application/pom.xml' 返回非零代码:1

[错误]命令'/bin/sh -c mvn clean install -Dmaven.wagon.http.ssl.insecure=true -Dmaven.wagon.http.ssl.allowall=true -DskipTests -f application/pom.xml'返回非零代码:1 [错误]/bin/docker 失败,返回代码:1 [部分]完成:构建映像
6

继续说这个问题绝对有效。 5xx 错误 A,来自服务器,IE 是你的,不是我的,B,这实际上是当你为你的项目传递这个错误时,谷歌中发生的第一个也是唯一的结果。现在,我并不是说这是您的实际错误并且您需要修复它,而是说它与本地网络有关是荒谬的,只会让用户白费力气。这肯定是由于 pom.xml 文件中的配置错误造成的。由于我是初学者,所以我不太适合解决这个问题,并且可能与存储库的最新更改与 5 年前的代码交互不良有关。我至少收到过一次 501 错误,它可能至少部分与 https 相关。这里不存在网络/防火墙问题,并且考虑到即使将 https 添加到某些嵌入的 xml 链接也会破坏路径并产生其中一些错误,我真的怀疑原始用户 pom.xml 中存在问题

由于这是谷歌搜索中的第一个结果,我将链接到对我有用的解决方案,以帮助其他人走上正确的道路。如果您不想收到此类消息,那是很不幸的,但在这种情况下,我完全建议删除或隐藏此问题,因为第一个结果实际上保证了大量困惑的用户进入以找出与部署相关的问题。

<pluginRepositories>
        <pluginRepository>
            <id>central</id>
            <name>Central Repository</name>
            <url>https://repo.maven.apache.org/maven2</url>
            <layout>default</layout>
            <snapshots>
                <enabled>false</enabled>
            </snapshots>
            <releases>
                <updatePolicy>never</updatePolicy>
            </releases>
        </pluginRepository>
    </pluginRepositories>
    <repositories>
        <repository>
            <id>central</id>
            <name>Central Repository</name>
            <url>https://repo.maven.apache.org/maven2</url>
            <layout>default</layout>
            <snapshots>
                <enabled>false</enabled>
            </snapshots>
        </repository>
    </repositories>

https://stackoverflow.com/questions/59763531/maven-dependency-are-failing-with-a-501-error

3

@Walters-Marissa 感谢您尝试提供帮助,但 Maven Central 不是我们的服务器。它由一家名为 Sonatype 的公司维护,该公司发表了一篇文章,解释了如何监视其状态并诊断连接问题。

声称它与本地网络有任何关系是荒谬的,只会让用户白费力气

这并不荒谬。本地网络问题完全有可能导致与远程服务器的连接问题。

这肯定是由于 pom.xml 文件中的配置错误造成的

事实也并非如此。问题可能是配置错误,但也可能有许多其他原因。

我将链接到对我有用的解决方案,以帮助其他人走上正确的道路

我认为这不是正确的道路。对于最新的 Maven 安装,不需要此配置,因为使用 HTTPS 连接的中央存储库是默认配置的一部分。

8

如果您认为这个错误是 Maven 版本固有的,那么你们就是造成这个问题的人。不过,我不会浪费更多的时间告诉你你错了。继续浪费时间捂住耳朵,而不是修复那些肯定会吸引更多你已经说过你不想要的注意力的东西。