【问题标题】:ERROR: Non-resolvable parent POM: Could not transfer artifact org.springframework.boot:spring-boot-starter-parent:pom错误:不可解析的父 POM:无法传输工件 org.springframework.boot:spring-boot-starter-parent:pom
【发布时间】:2018-11-07 09:54:19
【问题描述】:

尝试运行我的应用程序时,我的 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:1.5.18.BUILD-SNAPSHOT 
 from https://repo.spring.io/snapshot was cached in the local repository, resolution will not be 
 reattempted until the update interval of spring-snapshots has elapsed or updates are forced. 
 Original error: Could not transfer artifact org.springframework.boot:spring-boot-starter-
 parent:pom:1.5.18.BUILD-SNAPSHOT from/to spring-snapshots (https://repo.spring.io/
 snapshot): repo.spring.io and 'parent.relativePath' points at no local POM

下面是 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>

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

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

    <parent>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-parent</artifactId>
        <version>1.5.18.BUILD-SNAPSHOT</version>
        <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-actuator</artifactId>
        </dependency>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-data-jpa</artifactId>
        </dependency>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-jersey</artifactId>
        </dependency>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-security</artifactId>
        </dependency>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-web</artifactId>
        </dependency>

        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-devtools</artifactId>
            <scope>runtime</scope>
        </dependency>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-test</artifactId>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>org.springframework.security</groupId>
            <artifactId>spring-security-test</artifactId>
            <scope>test</scope>
        </dependency>
    </dependencies>

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

    <repositories>
        <repository>
            <id>spring-snapshots</id>
            <name>Spring Snapshots</name>
            <url>https://repo.spring.io/snapshot</url>
            <snapshots>
                <enabled>true</enabled>
            </snapshots>
        </repository>
        <repository>
            <id>spring-milestones</id>
            <name>Spring Milestones</name>
            <url>https://repo.spring.io/milestone</url>
            <snapshots>
                <enabled>false</enabled>
            </snapshots>
        </repository>
    </repositories>

    <pluginRepositories>
        <pluginRepository>
            <id>spring-snapshots</id>
            <name>Spring Snapshots</name>
            <url>https://repo.spring.io/snapshot</url>
            <snapshots>
                <enabled>true</enabled>
            </snapshots>
        </pluginRepository>
        <pluginRepository>
            <id>spring-milestones</id>
            <name>Spring Milestones</name>
            <url>https://repo.spring.io/milestone</url>
            <snapshots>
                <enabled>false</enabled>
            </snapshots>
        </pluginRepository>
    </pluginRepositories>


</project>

【问题讨论】:

    标签: spring-boot maven-3 pom.xml


    【解决方案1】:
    1. 将 spring boot starter 降级到较低版本。
    2. 更新 Maven 项目。

    希望它有效。

    【讨论】:

      【解决方案2】:

      您使用的 Spring Boot 版本存在问题,因为它是构建版本。只需复制 1.X 的另一个发行版本并替换它。

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

      【讨论】:

        【解决方案3】:

        如果您可以从浏览器访问 url https://repo.spring.io/snapshot/,则可能是 Maven 问题。 Maven 无法连接到存储库,这可能是由于:

        1. 下载的依赖项中的任何缓存问题。尝试删除本地依赖,试试here提供的解决方案。

        2. 尝试 Maven 更新和 Maven 清理。

        3. 执行上述操作后尝试重新打开 IDE。

        【讨论】:

          【解决方案4】:

          您的 pom.xml 很好,看来是您的 Internet 连接有问题。检查您是否可以使用浏览器访问https://repo.spring.io/snapshot/。如果是,请检查是否需要配置代理服务器。如果不是,您应该联系您的互联网提供商。

          这是关于如何为 Maven 配置代理服务器的documentation

          【讨论】:

          • 有帮助吗@user1245524
          猜你喜欢
          • 2018-05-19
          • 2012-11-10
          • 2022-07-30
          • 1970-01-01
          • 2023-03-05
          • 2021-05-18
          • 2021-08-22
          • 2016-06-15
          • 2012-07-25
          相关资源
          最近更新 更多