在父子项目中,想要单独打包一个子项目project-sub,进行clean操作,报错:
报错信息:

[INFO] Scanning for projects...
[ERROR] [ERROR] Some problems were encountered while processing the POMs:
[FATAL] Non-resolvable parent POM for cn.com.w-project_sub:0.0.1-SNAPSHOT: Could not find artifact cn.com.w:demo-parent:pom:0.0.1-SNAPSHOT and 'parent.relativePath' points at wrong local POM @ line 4, column 11 @ 
[ERROR] The build could not read 1 project -> [Help 1]
[ERROR]   
[ERROR]   The project cn.com.w-project_sub:0.0.1-SNAPSHOT (D:\demo\project_sub\pom.xml) has 1 error
[ERROR]     Non-resolvable parent POM for cn.com.w-project_sub:0.0.1-SNAPSHOT: Could not find artifact cn.com.w:demo-parent:pom:0.0.1-SNAPSHOT and 'parent.relativePath' points at wrong local POM @ line 4, column 11 -> [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

说明父项目demo-parent没有install,子项目在本地仓库找不到父项目的pom.xml文件。

那么对父项目demo-parent进行clean-install操作,发现还是报错。
注意:大多数情况下直接进行install操作不会报错。此处是由于习惯,无论进行什么操作,都先clean一下。所以才会发生以下错误。
不过也有少数情况无论对父项目demo-parent进行clean操作还是直接进行install操作,都报错,对于这种情况的解决办法如下:

[ERROR] [ERROR] Some problems were encountered while processing the POMs:
[FATAL] Non-resolvable parent POM for  cn.com.w-project_sub:0.0.1-SNAPSHOT: Could not find artifact cn.com.w:demo-parent:pom:0.0.1-SNAPSHOT and 'parent.relativePath' points at wrong local POM @ line 5, column 10
[FATAL] Non-resolvable parent POM for cn.com.w-project_sub02:0.0.1-SNAPSHOT: Could not find artifact cn.com.w:demo-parent:pom:0.0.1-SNAPSHOT and 'parent.relativePath' points at wrong local POM @ line 4, column 11

说明在对父项目demo-parent项目clean操作时,先要清楚子项目,但是子项目在clean时还要解析父项目的pom文件。此时产生了死循环。

解决办法:
在父项目的pom文件中的标签中的子项目全部注掉。然后对父项目进行clean-install操作。发现操作成功。

        <modules>
		<module>../project_sub</module>
		<module>../project_sub02</module>
	</modules>

操作成功后在把注掉的子项目在放开。再一次对父项目进行clean-install操作,发现操作成功。可以发现父项目和子项目全部install成功。
此时单独对子项目进行clean-install操作也可成功。

问题考虑:
问题出在父项目的pom文件在本地仓库或远程仓库不存在,所以在对子项目进行clean-package操作时会报错,解析不到父项目的pom文件。但是此时直接对父项目进行clean操作时,maven会先对子项目进行clean操作。就发生了死循环。但是直接对父项目进行install操作不会报错。

不过也有少数情况无论对父项目demo-parent进行clean操作还是直接进行install操作,都报错,对于这种情况只能进行上面的的处理操作。

posted on 2021-05-13 15:47  哑吧  阅读(9751)  评论(0编辑  收藏  举报