错误:不可解析的父POM:无法传输工件org.springframework.boot:spring-boot-starter-parent:pom

时间:2018-11-07 09:54:20

标签: spring-boot maven-3

当尝试运行应用程序时,我在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>

4 个答案:

答案 0 :(得分:0)

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

以下是文档,介绍如何为Maven配置代理服务器:https://maven.apache.org/guides/mini/guide-proxies.html

答案 1 :(得分:0)

您正在使用的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>

答案 2 :(得分:0)

如果您可以从浏览器访问URL https://repo.spring.io/snapshot/,则可能是maven问题,maven无法连接到存储库,原因可能是:

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

2)试试Maven更新并清理Maven。

3)完成上述操作后,尝试重新打开IDE。

答案 3 :(得分:0)

  1. 将spring boot启动器降级到较低版本。
  2. 更新Maven项目。

希望它能起作用。