【发布时间】:2020-11-22 04:34:43
【问题描述】:
我们假设我有两个实体(Subscription 和 Application),每个实体都有他的 Repository 层命名为(SubscriptionRepository 和 ApplicationRepository),每个都有两个 Service(ISubscriptionService 和 IApplicationService)
在某些情况下,假设我们最终得到 a case where ApplicationService need to inject SubscriptionService 和 a case where SubscriptionService need to inject ApplicationService (
反过来)当然它是一个循环依赖
我的问题是:
当我想将服务注入另一个时,我应该如何反思以免陷入此类问题。 (这意味着我如何决定是否需要将 ApplicationService 注入 SubscriptionService 或相反)?
【问题讨论】:
标签: spring dependency-injection architecture