Scala Can';t在服务中注入Actor系统
我正在尝试创建一个在我的应用程序后台运行的服务(读取和写入队列),我希望使用actor系统构建该服务。但是,当我尝试将ActorSystem注入我的类时,我遇到了一个错误:Scala Can';t在服务中注入Actor系统,scala,playframework,Scala,Playframework,我正在尝试创建一个在我的应用程序后台运行的服务(读取和写入队列),我希望使用actor系统构建该服务。但是,当我尝试将ActorSystem注入我的类时,我遇到了一个错误: play.api.UnexpectedException: Unexpected exception[CreationException: Unable to create injector, see the following errors: 1) Error injecting constructor, java.la
play.api.UnexpectedException: Unexpected exception[CreationException: Unable to create injector, see the following errors:
1) Error injecting constructor, java.lang.IllegalArgumentException: no matching constructor found on class services.Indexer$IndexActor for arguments []
at services.Indexer.<init>(Indexer.scala:21)
at Module.configure(Module.scala:6) (via modules: com.google.inject.util.Modules$OverrideModule -> Module)
while locating services.Indexer
在播放文档中,但这似乎只在您注入扩展控制器的类时起作用:
@Singleton
class MyController @Inject()(system: ActorSystem)(implicit exec: ExecutionContext) extends Controller {
// This works
}
发现问题:
在Module.scala中,我使用的是com.google.inject
包
import com.google.inject.AbstractModule // <-------
import services.Indexer
class Module extends AbstractModule {
override def configure() = {
bind(classOf[Indexer]).asEagerSingleton()
}
}
import com.google.inject.AbstractModule // <-------
import services.Indexer
class Module extends AbstractModule {
override def configure() = {
bind(classOf[Indexer]).asEagerSingleton()
}
}
import com.google.inject._