Maven says I have a cyclic reference in multi-module project but can't figure out why

时光怂恿深爱的人放手 提交于 2019-12-05 04:09:14

Ah! It was a misleading error.

The problem wasn't that there both module1 and module2 depended on each other. The problem was that module2 is a Maven plugin and in my root pom.xml I had the plugin in the section. I removed that plugin from the build and it started working.

It happened to me in this circumstances.

The module_child_X was specified 2 times at module_root pom.xml:

- As a module

(pom.xml of the root module)
<dependency>
    <groupId>module_root</groupId>
    <artifactId>module_child_X</artifactId>
    <version>0.0.1-SNAPSHOT</version>
    <type>jar</type>
</dependency>

- As a dependency

(pom.xml of the root module)
<modules>
    <module>module_child_X</module>
    ...
</modules>

Solution?

Removed the module_child_X as a dependency. It is already specified as a module.

I do nearly the same, and I use IDEA.

I have a project A, which depends on a module B. In the pom file of A, B was declared as a dependency. This is OK. In the pom file of B, A was declared as its parent. I removed this information, and as it was requested in the error message I added the version number of B in its pom file.

And now it is OK.

I had exactly the same issue in a multimodule ear project. The ejb pom had a dependency on the web module (compile scope) and the web pom a dependency on the ejb module. As soon as i removed the ejb's pom dependency on the web module, the project build fine. It makes sense that the intramodule dependencies must be unidirectional after all, in order to avoid cyclic references.

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