子模块依赖父模块后调用 maven 的 clean 命令报错: Some problems were encountered while processing the POMs

我最近在做一个公司的练手 Demo 项目,顺便调试下环境,然而我子模块依赖父模块时却总是出问题,我的项目结构如下

我想要实现的效果是 demo-parent 是 demo-project2 的子模块,demo-common 与 demo-server 是 demo-parent 的子模块

我的步骤是先创建这些模块,然后指定他们的依赖关系,在指定 demo-parent 为 demo-project2 的子模块时没有出现问题

然而在指定 demo-common 为 demo-parent 的子模块时却出现问题了,一旦在 demo-common 中的 pom 文件中写入如下代码

<parent>
    <groupId>org.example.sun</groupId>
    <artifactId>demo-parent</artifactId>
    <version>1.0.0</version>
    <relativePath/>
</parent>

此时对 demo-common 调用 maven 中的 clean 命令时会报下面的错误

[ERROR] [ERROR] Some problems were encountered while processing the POMs:
[FATAL] Non-resolvable parent POM for org.example:demo-common:1.0.0: Could not transfer artifact com.example.sun:demo-parent:pom:1.0.0 from/to maven-snapshots ( http://localhost/repository/maven-snapshots/): Failed to transfer file: http://localhost/repository/maven-snapshots/com/example/sun/demo-parent/1.0.0/demo-parent-1.0.0.pom. Return code is: 400 , ReasonPhrase:Repository version policy: SNAPSHOT does not allow version: 1.0.0. and 'parent.relativePath' points at no local POM @ line 5, column 13
 @ 
[ERROR] The build could not read 1 project -> [Help 1]
[ERROR]   
[ERROR]   The project org.example:demo-common:1.0.0 (C:\Users\Iverson_xue\IdeaProjects\demo-project2\demo-common\pom.xml) has 1 error
[ERROR]     Non-resolvable parent POM for org.example:demo-common:1.0.0: Could not transfer artifact com.example.sun:demo-parent:pom:1.0.0 from/to maven-snapshots ( http://localhost/repository/maven-snapshots/): Failed to transfer file: http://localhost/repository/maven-snapshots/com/example/sun/demo-parent/1.0.0/demo-parent-1.0.0.pom. Return code is: 400 , ReasonPhrase:Repository version policy: SNAPSHOT does not allow version: 1.0.0. and 'parent.relativePath' points at no local POM @ line 5, 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

一旦注释掉这行代码,则不会报这个错误

补充:由于这是公司的项目,因此上面的报错对可能暴露公司信息的内容做了修改,example 为公司的域名地址,而 localhost 则为公司的内网 ip 地址

解决方法:

<relativePath/>表示从服务器下载 parent.pom
将其改为
<relativePath>../demo-parent/pom.xml</relativePath>

即可解决该问题

评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值