如果我在扩展类中注入,Guice注入null

时间:2018-08-29 01:05:26

标签: dependency-injection guice

我有一堂课

class BaseApplication: @Inject constructor(protected val someType: SomeType)

和扩展类

class Application: @Inject constructor(someType: SomeType, protected val otherType:OtherType) : BaseApplication(someType)
ApplicationotherType上的

为空,直到我在BaseApplication的ctor中声明它为止。

configure功能:

override fun configure(binder: Binder) {
    with(binder) {
        bind(SomeType::class.java).toInstance(SomeType())
        bind(OtherType::class.java).toInstance(OtherType())
        bind(Application::class.java).asEagerSingleton()
    }
}

为什么呢?

0 个答案:

没有答案