Maven:Non-resolvable parent POM and ‘parent.relativePath‘ points at no local POM

本文讲述了如何解决Idea中Maven项目结构中,由于parent pom.xml配置问题导致的编译错误,重点在于正确设置`<relativePath>`。通过修改`mall-admin`模块的pom.xml,将`<relativePath/>`更改为`<relativePath>../pom.xml</relativePath>`,解决了依赖找不到的问题。

idea项目结构如下图,mall项目下有多个moudles,每个moudles内有各自的pom.xml文件

 

mall/pom.xml配置如下(注意关注parent部分)

<?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.macro.mall</groupId>
    <artifactId>mall</artifactId>
    <version>1.0-SNAPSHOT</version>
    <packaging>pom</packaging>

    <modules>
        <module>mall-common</module>
        <module>mall-mbg</module>
        <module>mall-demo</module>
        <module>mall-admin</module>
        <module>mall-search</module>
        <module>mall-portal</module>
    </modules>

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

mall/mall-admin/pom.xml配置如下(注意 relativePath 配置)

<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/maven-v4_0_0.xsd">
    <modelVersion>4.0.0</modelVersion>

    <groupId>com.macro.mall</groupId>
    <artifactId>mall-admin</artifactId>
    <version>1.0-SNAPSHOT</version>
    <packaging>jar</packaging>
    <name>mall-admin</name>

    <parent>
        <groupId>com.macro.mall</groupId>
        <artifactId>mall</artifactId>
        <version>1.0-SNAPSHOT</version>
        <relativePath />
    </parent>
</project>

 

idea 使用maven编译报错如下

resolution will not be reattempted until the update interval of central has elapsed or updates are forced and 'parent.relativePath' points at no local POM

[ERROR] [ERROR] Some problems were encountered while processing the POMs:
[FATAL] Non-resolvable parent POM for com.macro.mall:mall-admin:1.0-SNAPSHOT: Failure to find com.macro.mall:mall:pom:1.0-SNAPSHOT in http://maven.aliyun.com/nexus/content/groups/public was cached in the local repository, resolution will not be reattempted until the update interval of central has elapsed or updates are forced and 'parent.relativePath' points at no local POM @ line 20, column 13
 @ 
[ERROR] The build could not read 1 project -> [Help 1]
[ERROR]   
[ERROR]   The project com.macro.mall:mall-admin:1.0-SNAPSHOT (D:\work\workspace\mall\mall-admin\pom.xml) has 1 error
[ERROR]     Non-resolvable parent POM for com.macro.mall:mall-admin:1.0-SNAPSHOT: Failure to find com.macro.mall:mall:pom:1.0-SNAPSHOT in http://maven.aliyun.com/nexus/content/groups/public was cached in the local repository, resolution will not be reattempted until the update interval of central has elapsed or updates are forced and 'parent.relativePath' points at no local POM @ line 20, column 13 -> [Help 2]
[ERROR] 
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR] 
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/ProjectBuildingException
[ERROR] [Help 2] http://cwiki.apache.org/confluence/display/MAVEN/UnresolvableModelException
Process finished with exit code 1

 

解决问题  

修改 mall/mall-admin/pom.xml 文件,替换 <relativePath />  为  <relativePath>../pom.xml</relativePath> 即可解决问题

 

问题原因:

modules内的pom.xml的parent依赖找不到所依赖的内容。

评论 1
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
红包 添加红包
表情包 插入表情
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值