找不到类型为io.finch.Decode.Json的证据参数的隐含值

时间:2017-04-17 19:29:41

标签: finch circe

一直在研究这个问题几天仍然不知道发生了什么: 有了一个finch Web服务,build.sbt依赖项看起来像:

  "com.github.finagle" %% "finch-circe" % finchVersion changing(),
  "com.github.finagle" %% "finch-core" % finchVersion changing(),
  "com.github.finagle" %% "finch-jackson" % finchVersion changing(),
  "com.github.finagle" %% "finch-test" % finchVersion changing(),
  "com.twitter" %% "twitter-server" % "1.28.0",

雀科版本为0.14.0。 端点看起来像:

  def makeService(statsReceiver: StatsReceiver): Service[Request, Response] = {
    //val getUserCounter = statsReceiver.counter("get_user_counter")
    (
      MyEndpoint.endpoint1()
        :+: SomeEndpoint.deleteEntity()
        :+: SomeEndpoint.createEntity()
        :+: SomeEndpoint.updateEntity()
      ) handle {
      case e: InvalidClientError => Unauthorized(e)
      case e: InvalidContextError => BadRequest(e)
      case e: RelevanceError => BadRequest(e)
      case e: Exception => InternalServerError(e)
    } toService

我在“toService”行上收到错误消息,如:

[error] /workplace/relevance-service/src/main/scala/com/company/service/endpoint/serviceEndpoints.scala:39: An Endpoint you're trying to convert into a Finagle service is missing one or more encoders.
[error]
[error]   Make sure Exception is one of the following:
[error]
[error]   * A com.twitter.finagle.http.Response
[error]   * A value of a type with an io.finch.Encode instance (with the corresponding content-type)
[error]   * A coproduct made up of some combination of the above
[error]

我看了看: https://github.com/finagle/finch/blob/master/docs/src/main/tut/cookbook.md#fixing-the-toservice-compile-error

并尝试了以下几行:

import io.finch.circe._

首先,代码中没有使用此io.finch.circe._,因为它在IDE中是灰色的。而且我仍然遇到相同的构建错误。我完全迷失在这里。任何人都可以帮助我,我在这里失踪了什么? google / bing around并没有给我任何有用的东西。

感谢。

0 个答案:

没有答案