首页 > 解决方案 > Maven 构建 pom 失败

问题描述

我从spring初始化程序下载了一个spring项目,并通过maven将它导入到sts中。

不幸的是,构建不断失败,出现以下错误:

项目构建错误:com.dellteam:firstmicroservice:0.0.1-SNAPSHOT 的不可解析父 POM:无法
从/到传输工件 org.springframework.boot:spring-boot-starter-parent:pom:2.1.0.RELEASE spring-milestones (https://repo.spring.io/milestone):连接重置和“parent.relativePath”点在没有本地 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.dellteam</groupId>
    <artifactId>firstmicroservice</artifactId>
    <version>0.0.1-SNAPSHOT</version>
    <packaging>jar</packaging>

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

    <parent>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-parent</artifactId>
        <version>2.1.0.RELEASE</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>
        <spring-cloud.version>Greenwich.M1</spring-cloud.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-web</artifactId>
        </dependency>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-webflux</artifactId>
        </dependency>
        <dependency>
            <groupId>org.springframework.cloud</groupId>
            <artifactId>spring-cloud-starter-gateway</artifactId>
        </dependency>

        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-test</artifactId>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>io.projectreactor</groupId>
            <artifactId>reactor-test</artifactId>
            <scope>test</scope>
        </dependency>
    </dependencies>

    <dependencyManagement>
        <dependencies>
            <dependency>
                <groupId>org.springframework.cloud</groupId>
                <artifactId>spring-cloud-dependencies</artifactId>
                <version>${spring-cloud.version}</version>
                <type>pom</type>
                <scope>import</scope>
            </dependency>
        </dependencies>
    </dependencyManagement>

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

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


</project>

我以为我的 ISP 不允许我访问https://repo.spring.io/milestone/,但事实并非如此。这个网址对我来说是完全可以访问的。

我现在尝试清理和构建几次并删除.m2 文件夹并再次尝试重建项目,但结果是相同的。

任何帮助将不胜感激。

标签: javamavenspring-boot

解决方案


将 Spring Plugin Release Repo 添加到 Plugin-Repositories。这样它就可以找到spring-boot-maven-plugin-2.1.0.RELEASE。在标签下添加以下行,如下所示:

<project>
  <!------ others lines -->
    <pluginRepositories>
     <pluginRepository>
        <id>repository.spring.release</id>
        <name>Spring GA Repository</name>
        <url>https://repo.spring.io/plugins-release/</url>
    </pluginRepository>
   </pluginRepositories>
 </project>

有关更多信息,请检查 --> Spring boot starter parent 2.0.0 not found 依赖项


推荐阅读