Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/scala/19.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Scala Can';t在服务中注入Actor系统_Scala_Playframework - Fatal编程技术网

Scala Can';t在服务中注入Actor系统

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

我正在尝试创建一个在我的应用程序后台运行的服务(读取和写入队列),我希望使用actor系统构建该服务。但是,当我尝试将ActorSystem注入我的类时,我遇到了一个错误:

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._