1

I'm cutting my teeth on Akka HTTP by working this example. For the purposes of learning, I converted it to a Maven project. However, I'm getting compilation errors as follows using Akka v2.3.12 and Akka Stream v1.0. The POST DSL fails with similar errors that I'm not posting for brevity. How can I get the example to run?

pathPrefix("ip") {
(get & path(Segment)) { ip =>
  complete {
    fetchIpInfo(ip).map[ToResponseMarshallable] {
      case Right(ipInfo) => ipInfo
      case Left(errorMessage) => BadRequest -> errorMessage
    }
  }
}

[ERROR]  found   : akka.http.scaladsl.server.Directive[(String,)]
[ERROR]  required: ?{def apply: ?}
[ERROR] Note that implicit conversions are not applicable because they are ambiguous:
[ERROR]  both method addDirectiveApply in object Directive of type [L](directive: akka.http.scaladsl.server.Directive[L])(implicit hac: akka.http.scaladsl.server.util.ApplyConverter[L])hac.In => akka.http.scaladsl.server.Route
[ERROR]  and method fromDirective in object ConjunctionMagnet of type [L, R](other: akka.http.scaladsl.server.Directive[R])(implicit join: akka.http.scaladsl.server.util.TupleOps.Join[L,R])akka.http.scaladsl.server.ConjunctionMagnet[L]{type Out = akka.http.scaladsl.server.Directive[join.Out]}
[ERROR]  are possible conversion functions from akka.http.scaladsl.server.Directive[(String,)] to ?{def apply: ?}
[ERROR]         (get & path(Segment)) { ip =>

error: akka.http.scaladsl.server.Directive[(String,)] does not take parameters
[ERROR]         (get & path(Segment)) { ip =>
4

1 回答 1

1

事实证明,这是由于implicitSpray(以及 akka-http)使用的深层链,因此正确导入至关重要。很少有示例显示导入以及使用旧库的示例。

于 2015-09-10T07:40:53.363 回答