Maven multi module project cannot find sibling module

£可爱£侵袭症+ 提交于 2019-11-28 00:51:40

When you are building a multi-module Maven project, you need to run Maven commands from the root POM. This means you need to run mvn clean install on Product's pom.xml.

The error you are getting is expected: you are only building Model. In Model's POM, Maven sees that there is a dependency on MagniCompCommon so it tries to look for that dependency. First, it searches in your local repo: it fails to find it there since you did not install MagniCompCommon before. As a result, it looks for it in the predefined remote repositories (and also fails to find it).

You would be able to circumvent this by first running mvn clean install on MagniCompCommon's POM, then on Model POM but this is much easier done by invoking Maven directly on the root POM. It will correctly build every modules in the right order (since Model depends on MagniCompCommon, it will build MagniCompCommon first, then Model).

As a side note, you can remove the line <packaging>jar</packaging> because this is the default.

javaguest

I noticed MagniCompCommon pom doesnt specify a version

<!-- <groupId>com.magnicomp.common</groupId> -->
<artifactId>MagniCompCommon</artifactId>
<packaging>jar</packaging>

And in Product pom, you're referencing version 1.0

<dependency>
    <groupId>com.magnicomp</groupId>
    <artifactId>MagniCompCommon</artifactId>
    <version>1.0</version>
</dependency>

Have you tried specifying version 1.0 in MagniCompCommon pom?

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!