英文:
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.
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论