【发布时间】:2021-02-10 13:08:14
【问题描述】:
我知道在here 描述的直接依赖的情况下,空的beans.xml 可以如何解决问题
问题是当子模块之间的依赖方向相反时,我们如何才能达到类似的结果。 所以基于链接问题的例子 如果不是这个设置会怎样
// service-module build.gradle
dependencies {
implementation project(":library-module")
}
我们有这个
// library-module build.gradle
dependencies {
implementation project(":service-module")
}
作为一个用例,考虑一个遵循ports & adapters 架构的服务,
其中端口位于application 模块中,适配器实现位于adapters 模块中。
// application module
public interface WebPort {}
---
@ApplicationScoped
public class AppService {
@Inject
WebPort webPort;
...
}
//adapters module
// build.gradle
dependencies {
// this is in order to have the WebPort available
implementation project(":application")
}
@ApplicationScoped
public class WebAdapter implements WebPort {
...
}
目前,此设置会抛出 UnsatisfiedResolutionException,因为应用程序模块无法看到 WebAdapter bean。
是否可以有类似的工作设置?
【问题讨论】:
标签: gradle dependency-injection cdi quarkus multi-module