Maven cyclic dependency

后端 未结 2 1725
佛祖请我去吃肉
佛祖请我去吃肉 2021-01-26 18:43

my maven project has multiple maven modules. Two of those modules (product and feature) are dependent on each other. When I include the modules as dependencies in the pom files,

相关标签:
2条回答
  • 2021-01-26 19:10

    It may not work for your particular situation but another option to rectify cyclical dependencies is to use events.

    First, set your modules up in a tree with no cyclical dependencies. Put your Event classes at the top of the tree. Then publish and listen for events in any of the modules. This allows you to have modules that communicate with each other without depending on each other.

    For how to publish and listen for events in Spring see:

    https://spring.io/blog/2015/02/11/better-application-events-in-spring-framework-4-2

    0 讨论(0)
  • 2021-01-26 19:31

    Design smell.

    Refactor your modules. Basically everything which is needed in both modules should go into a common dependency. You cannot have cycles in your dependency tree, it just won't work.

    0 讨论(0)
提交回复
热议问题