在DDD中必须将Service和Domain,与Repository放在两个不同的层中,若直接这样设计的话,会出现包之间循环应用的现象, 比如Service引用Infrastrator中的Repository,Repository又引用Domain Layer中的Domain。

可用以下解决方法,引入Reposityor的接口IReposityor,Service和Domain引用IReposityor,在通过IOC注入Reposityor到接口IReposityor中

本文探讨了解决DDD架构中Service层与Repository层之间的循环依赖问题。通过引入Repository接口IRepository,并利用依赖注入的方式,实现Service层和Domain层与具体实现的Repository解耦。
在DDD中必须将Service和Domain,与Repository放在两个不同的层中,若直接这样设计的话,会出现包之间循环应用的现象, 比如Service引用Infrastrator中的Repository,Repository又引用Domain Layer中的Domain。

可用以下解决方法,引入Reposityor的接口IReposityor,Service和Domain引用IReposityor,在通过IOC注入Reposityor到接口IReposityor中

3779
1211

被折叠的 条评论
为什么被折叠?