-18

maven 多模块拆分导致循环依赖问题

 1 year ago
source link: https://www.v2ex.com/t/865566
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.

V2EX  ›  Java

maven 多模块拆分导致循环依赖问题

  ChenGangS · 2 小时 27 分钟前 · 319 次点击

新人第一次提问,感谢各位大佬

是我的一个练手项目,目前使用了 springBoot ,我拆分了一个系统模块,OA 模块
系统模块包含了基本的后台管理和用户授权那块,同时还包含了 springboot 的启动类
OA 模块包含了 OA 的审批功能等等。

现在遇到的问题:

系统模块中有一个用户服务,我在 OA 模块里需要用到它, 我就需要在 OA 模块中引入系统模块才能使用到这个服务
而系统模块中必须引入 OA 模块以便被 spring 扫描,那么问题就来了,就发生了 A 需要 B ,B 需要 A 的循环依赖问题。

我想到的解决方案:

改造系统模块,拆分成多个 module ,分别单独暴露出 service 和 mapper 等类,让 OA 单独引用这个暴露的 service 模块而不需要引用整个系统模块

1.我想知道这样做是否可行,会有其他坑嘛
2.是否为主流的解决方案
3.我想知道还有其他解决方案嘛


About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK