今天尝试着将原来的项目改为多模块,在项目改造过程中遇到一坑,花了不少时间,最终得以解决。
项目结构:
其中order是父模块,以下的都是子模块,order-common是一些通过信息模块,其他两个子模块对order-common都有依赖,但是在maven clean的时候项目就会有报错提示:
The build could not read 1 project -> [Help 1]
The project com.imooc:order-common:1.0.1.SNAPSHOT (E:\CompanyProject\yunnan\IMOOC\SpringCloudLearn\order\order-common\pom.xml) has 1 error
Non-resolvable parent POM for com.imooc:order-common:1.0.1.SNAPSHOT: Failure to find com.imooc:order:pom:1.0.1.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 aliyun has elapsed or updates are forced and 'parent.relativePath' points at wrong local POM @ line 5, column 11 -> [Help 2]
To see the full stack trace of the errors, re-run Maven with the -e switch.
Re-run Maven using the -X switch to enable full debug logging.
For more information about the errors and possible solutions, please read the following articles:
[Help 1] http://cwiki.apache.org/confluence/display/MAVEN/ProjectBuildingException
[Help 2] http://cwiki.apache.org/confluence/display/MAVEN/UnresolvableModelException
网上大多数都是说是子模块找不到父模块,设置<relativePath/>,但是设置后问题仍未能解决。
我注释掉pom中的<parent>再单个的模块的进行clean,order-common模块提示,
'version' uses an unsupported snapshot version format, should be '*-SNAPSHOT' instead. @ line 13, column 12
一看报错,检查下<version>,果然是格式问题<version>1.0.1.SNAPSHOT</version>
,修改<version>
<parent>
<artifactId>order</artifactId>
<groupId>com.imooc</groupId>
<version>1.0.1-SNAPSHOT</version>
</parent>
修改后项目clean ,compile , install 都正常。