简体   繁体   English

找不到参数系统的隐含值:akka.actor.ActorSystem

[英]could not find implicit value for parameter system: akka.actor.ActorSystem

I am creating a unit test case for an Akka Actor using TestActorRef . 我正在使用TestActorRef为Akka Actor创建一个单元测试用例。

def actorRefFactory = context
        implicit def executionContext = actorRefFactory.dispatcher
        implicit val OutputActor = actorRefFactory.actorOf(Props[OutputActor], "OutputActor")

        val actorRef = TestActorRef[OutputActor]
        val actor = actorRef.underlyingActor

Getting the following error in creation of actorRef: 在创建actorRef时出现以下错误:

- could not find implicit value for parameter system: akka.actor.ActorSystem
    - not enough arguments for method apply: (implicit t: 
     scala.reflect.ClassTag[org.musigma.muhpc.OutputActor], implicit system: 
     akka.actor.ActorSystem)akka.testkit.TestActorRef[org.musigma.muhpc.OutputActor] in object 
     TestActorRef. Unspecified value parameter system.

I am very new to this. 我对此很新。 Kindly help. 请帮助。

All instances of actors, TestActorRef or actual real instances, need an ActorSystem to reside in. The methods that instantiate and start actors (again, test or otherwise) require an implicit ActorSystem to be in scope so that the underlying code creating that actor knows where to put it. 所有actor, TestActorRef或实际实例都需要一个ActorSystem驻留。实例化和启动actor的方法(再次,测试或其他方式)需要一个implicit ActorSystem在范围内,以便创建该actor的底层代码知道在哪里把它。

So, taking that into account, you just need to make sure that you add a line of code like this at the start of your test code: 因此,考虑到这一点,您只需要确保在测试代码的开头添加一行代码:

implicit val system = ActorSystem()

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 IO(Http)导致错误“无法找到参数系统的隐式值:akka.actor.ActorSystem” - IO(Http) is cause the error “could not find implicit value for parameter system: akka.actor.ActorSystem” 无结果的类型测试:Option [akka.actor.ActorSystem]类型的值也不能是akka.actor.ActorSystem - fruitless type test: a value of type Option[akka.actor.ActorSystem] cannot also be a akka.actor.ActorSystem 找不到ActorSystem的隐式值 - Could not find implicit value for ActorSystem 找不到参数FromRequestUnmarshaller Akka的隐式值 - could not find implicit value for parameter FromRequestUnmarshaller Akka 无法使用akka.actor.ActorContext创建肉桂指标,但是当我使用akka.actor.ActorSystem时,肉桂指标工作正常 - Unable to create cinnamon metrics with akka.actor.ActorContext but when I use akka.actor.ActorSystem, then cinnamon metrics works fine akka-http:找不到参数解组的隐含值 - akka-http : could not find implicit value for parameter unmarshalling 找不到参数超时的隐式值:akka.util.Timeout - could not find implicit value for parameter timeout: akka.util.Timeout 使用Akka播放2.5 - 找不到参数超时的隐含值:akka.util.Timeout - Play 2.5 with Akka - could not find implicit value for parameter timeout: akka.util.Timeout 这作为隐式参数-找不到参数的隐式值 - this as implicit parameter - could not find implicit value for parameter 无法找到参数的隐含值 - Could not find implicit value for parameter
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM