相关疑难解决方法(0)

在升级到喷雾1.2后,喷射Marshaller的期货不在隐含范围内

在更新到喷雾1.2后,我遇到了一个与我的JSON-Marshallers完全兼容的问题.在HttpService中执行以下操作

trait TestHttpService extends HttpService with SprayJsonSupport with DefaultJsonProtocol{ self : ActorLogging =>
    case class Test(hallo: String, test: String)
    implicit val storyJsonFormat = jsonFormat2(Test.apply)

    def test(implicit m : Marshaller[Future[Test]]) = 17
    def hallo = test 
}
Run Code Online (Sandbox Code Playgroud)

导致以下错误:

could not find implicit value for parameter marshaller:
spray.httpx.marshalling.Marshaller[scala.concurrent.Future[amanuensis.story.Story]]
Run Code Online (Sandbox Code Playgroud)

当我删除未来时,一切运作良好:

trait TestHttpService extends HttpService with SprayJsonSupport with DefaultJsonProtocol { self : ActorLogging =>
    case class Test(hallo: String, test: String)
    implicit val storyJsonFormat = jsonFormat2(Test.apply)

    def test(implicit m : Marshaller[Test]) = 17
    def hallo …
Run Code Online (Sandbox Code Playgroud)

scala future akka spray

9
推荐指数
1
解决办法
2463
查看次数

在Akka直接使用期货

我无法按照此处的说明创建未来.它表示您可以Future使用以下代码直接创建:

import akka.dispatch.Await
import akka.dispatch.Future
import akka.util.duration._

val future  = Future {
  "Hello" + "World"
}
val result = Await.result(future, 1 second)
Run Code Online (Sandbox Code Playgroud)

使用完全相同的代码,我得到一个错误消息,说:error: could not find implicit value for parameter executor: akka.dispatch.ExecutionContext.所有我能找到的ExecutionContext就是,你可以用它"做事".在文档中,我发现的唯一一行是:

implicit val ec = ExecutionContect.fromExecutionService(yourExecutionServiceGoesHere)
Run Code Online (Sandbox Code Playgroud)

但这对我没用.有人对我这个话题有什么建议吗?如何在Future不询问的情况下创建新的Actor

scala future akka

2
推荐指数
1
解决办法
3845
查看次数

标签 统计

akka ×2

future ×2

scala ×2

spray ×1