首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >错误更正:- required:spray.httpx.marshalling.ToResponseMarshallable

错误更正:- required:spray.httpx.marshalling.ToResponseMarshallable
EN

Stack Overflow用户
提问于 2014-09-11 04:25:21
回答 2查看 1.1K关注 0票数 1

我是Scala的新手,正在尝试编写一些REST API。我使用的是Scala 11.2、Spray 1.3.1和akka 2.3.6。

我基本上是在试着从spray编译一个例子。我得到的每条路由的错误是:类型不匹配;找到:字符串(“pong!”)必需: spray.httpx.marshalling.ToResponseMarshallable

我不确定这是一个版本不兼容的问题,还是我遗漏了一个引用。

下面是我的路由定义,取自spray示例:

代码语言:javascript
复制
package com.Shenandoah.SBIR.httpInterface


    import spray.routing.HttpService

    trait HttpInterface extends HttpService {  


      def pingRoute = path("ping") {
        get { complete("pong!!!!!!!!") }
      }

      def pongRoute = path("pong") {
        get { complete("pong!?") }
      }

        def pipRoute = path("pip") {
        get { complete("moonshine") }
      }

      def rootRoute = pingRoute ~ pongRoute ~ pipRoute
    }

    Here is the actor:

    package com.Shenandoah.SBIR.httpInterface

    import akka.actor._

    class HttpInterfaceActor extends HttpInterface with Actor {
      // the HttpService trait defines
      // only one abstract member, which connects the services environment
      // to the enclosing actor or test.
      def actorRefFactory = context


      def receive = runRoute(rootRoute)

}

EN

回答 2

Stack Overflow用户

发布于 2014-09-23 22:39:51

您可能正在使用针对Scala2.10的依赖项"io.spray" % "spray-routing" % "2.3.6"。有一个Spray版本没有指定Scala版本,它是针对Scala 2.10编译的。这是不幸的。

使用"io.spray" %% "spray-routing" % "2.3.6" (注意双重%)来拉入与您的Scala版本匹配的依赖项。这将适用于Scala 2.10和2.11。

票数 3
EN

Stack Overflow用户

发布于 2014-09-11 04:48:31

看起来您缺少默认的封送处理程序。尝试添加到您的导入:

代码语言:javascript
复制
import spray.httpx.marshalling.Marshaller
票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/25774478

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档