"的原因找不到参数rs的隐含值:spray.routing.RoutingSettings"

时间:2014-11-28 04:13:29

标签: scala spray

正好跟随(或者我认为)https://github.com/spray/spray-template/blob/on_spray-can_1.3/src/main/scala/com/example/MyService.scala的例子,我遇到了这个错误:

[error] /Users/alias/dev/src/main/scala/framework/MyActor.scala:86: could not find implicit value for parameter rs: spray.routing.RoutingSettings
[error]   def receive = runRoute(routes)
[error] 

并且无法弄清楚为什么看似相同的代码不起作用。

2 个答案:

答案 0 :(得分:3)

我发现this指出了使用implicitly调整问题的正确方向

implicitly[RoutingSettings]

从那里我能够确定存在含糊不清的隐含

Multiple markers at this line
    - implicit ActorRefFactory required: if outside of an Actor you need an implicit ActorSystem, inside of an actor this should be the implicit ActorContext
    - not enough arguments for method default: (implicit refFactory: akka.actor.ActorRefFactory)spray.routing.RoutingSettings. Unspecified value parameter 
     refFactory.
    - ambiguous implicit values: both value context in trait Actor of type => akka.actor.ActorContext and method system in trait ActorContext of type => 
     akka.actor.ActorSystem match expected type akka.actor.ActorRefFactory

我最终解决的是由我的演员中的import context._引起的

这让我花了很长时间才能解决问题,所以希望这将为人们节省大量时间!

答案 1 :(得分:1)

尝试添加:def actorRefFactory = context