调用注入斯卡拉类我在玩下面的类斯卡拉是注入其他类:从阿卡演员
class MainEtl2 @Inject() (ic: injectedClass) {
def run (option: String) = {
ic.method1()
// ... some code
}
}
我需要调用方法run
在阿卡演员。这是我的尝试,假设当调用MainEtl2
吉斯将注入injectedClass
:
class MainEtl extends Actor {
@Inject val me2 : MainEtl2
def receive = {
case option: String => {
val x = me2.run(option)
// ... more code
}
}
}
MainEtl
类不与followint错误编译:
class MainEtl needs to be abstract, since value me2 is not defined
如何使这项工作?
你有没有尝试在'MainEtl'的构造函数中注入'me2'? –
是的,看到我的评论以下答案 – ps0604