Maven多模块项目循环依赖问题

huangapple go评论58阅读模式
英文:

Maven multi module project Cyclic Dependency Issue

问题

我在我的Maven多模块项目中有以下模块:

父模块,子模块1

子模块1和子模块2都依赖于公共模块。因此,我已经在子模块1和子模块2的pom文件中都添加了公共模块的依赖。

但现在我不知何故也需要在子模块2中添加子模块1的依赖。是否有任何方法可以更改我的结构,以支持我的需求,而不会导致循环依赖问题?

英文:

I have the following modules in my Maven multi module project:

**Parent module ,Child1 module

Both Child1 and Child2 are dependent on Common Module.So I have added Common module dependency on both pom files of Child1 and Child2.

But now I somehow need to add Child2 dependency on as well .Is there any way I can make a change to my structure so that it can support my requirement and don't lead to cyclic dependency problem.

答案1

得分: 1

你可以:

  • 将Child2中的类移动到Common中。
  • 定义另一个名为Z的模块,将通用类移动到其中,然后让Child2和Common声明对Z的依赖。
  • 将Child2和Common合并成一个模块。
英文:

You can:

  • Move classes from Child2 to Common.
  • Define another module Z to which you move common classes, and then let Child2 and Common declare a dependency on Z.
  • Merge Child2 and Common into one module.

huangapple
  • 本文由 发表于 2020年8月6日 00:10:30
  • 转载请务必保留本文链接:https://go.coder-hub.com/63269228.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定