You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

Spring Boot项目pom.xml父POM依赖解析失败求助

解决Spring Boot项目Parent POM无法解析的问题

错误说明

Project build error: Non-resolvable parent POM for com.example:demo:0.0.1-SNAPSHOT: org.springframework.boot:spring-boot-starter-parent:pom:2.7.3 failed to transfer from https://repo.maven.apache.org/maven2 during a previous attempt. This failure was cached in the local repository and resolution is not 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.7.3 from/to central (https://repo.maven.apache.org/maven2): repo.maven.apache.org and 'parent.relativePath' points at no local POM

核心问题是Maven此前尝试下载spring-boot-starter-parent:2.7.3失败,失败状态被本地仓库缓存,默认不会自动重试;同时本地无对应父POM文件可通过relativePath加载。

解决方案

  • 强制触发依赖更新:在项目根目录执行以下命令,强制刷新依赖并重新尝试下载缺失的POM:

    mvn clean install -U
    

    -U参数会让Maven忽略缓存的更新间隔,重新从仓库拉取依赖。

  • 配置国内镜像加速(针对网络问题):如果是网络无法正常访问中央仓库导致的下载失败,修改Maven的settings.xml文件(路径通常为~/.m2/settings.xml或Maven安装目录下的conf/settings.xml),添加阿里云镜像:

    <mirrors>
        <mirror>
            <id>aliyunmaven</id>
            <mirrorOf>central</mirrorOf>
            <url>https://maven.aliyun.com/repository/public</url>
        </mirror>
    </mirrors>
    

    配置完成后重新执行mvn clean install。

  • 手动清理本地缓存:若强制更新仍无效,手动删除本地仓库中缓存的失败依赖目录:

    1. 找到本地Maven仓库默认路径(通常为~/.m2/repository)
    2. 删除org/springframework/boot/spring-boot-starter-parent/2.7.3目录
    3. 重新执行mvn clean install
  • 确认relativePath配置:你的pom.xml中<relativePath/>配置正确,会优先从远程仓库查找父POM,无需修改该配置,除非你有本地存放的父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 
  https://maven.apache.org/xsd/maven-4.0.0.xsd">
 <modelVersion>4.0.0</modelVersion>
 <parent>
    <groupId>org.springframework.boot</groupId>
    <artifactId>spring-boot-starter-parent</artifactId>
    <version>2.7.3</version>
    <relativePath/> <!-- lookup parent from repository -->
   </parent>
   <groupId>com.example</groupId>
  <artifactId>demo</artifactId>
  <version>0.0.1-SNAPSHOT</version>
   <name>demo</name>
   <description>Demo project for Spring Boot</description>
  <properties>
    <java.version>17</java.version>
  </properties>
  <dependencies>
    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-data-jdbc</artifactId>
    </dependency>
    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-data-jpa</artifactId>
    </dependency>

    <dependency>
        <groupId>org.postgresql</groupId>
        <artifactId>postgresql</artifactId>
        <scope>runtime</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>

内容的提问来源于stack exchange,提问作者54V4G3208

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.08.20 12:57:26