Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/scala/18.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Scala 同一类型上的类型不匹配_Scala_Marshalling_Spray - Fatal编程技术网

Scala 同一类型上的类型不匹配

Scala 同一类型上的类型不匹配,scala,marshalling,spray,Scala,Marshalling,Spray,我正在尝试使用spray路由发送json响应 我在调用complete后出现此错误 Error:(45, 29) type mismatch; found : _2.Entities.EventsSearchResponse where val _2: eyein.eventful.eventful required: _3.Entities.EventsSearchResponse where val _3: eyein.eventful.eventful

我正在尝试使用spray路由发送json响应 我在调用complete后出现此错误

Error:(45, 29) type mismatch;
 found   : _2.Entities.EventsSearchResponse where val _2: eyein.eventful.eventful
 required: _3.Entities.EventsSearchResponse where val _3: eyein.eventful.eventful
                api.jsonize(value)
                            ^
api.jsione
只是
封送处理的包装

在原始api文件中使用它可以毫无问题地将json打印为字符串

我最感兴趣的是这个错误,很明显有一些打字问题,但我不确定从哪里开始

这是路线

val myRoute =
  path("event" / IntNumber / IntNumber) {(from,to) =>
    get {
      respondWithMediaType(`application/json`) {
        onSuccess(api.GetEventsByDate(from.toString,to.toString)){ value =>
            complete{
              api.jsonize(value)
            }
          }
        }
      }
    }
jsonize签名

  def jsonize(eventList : Entities.EventsSearchResponse)

Scala认为内部类的类型是路径依赖的,并且并不总是按照预期的方式推断路径依赖的类型。尝试为其指定显式路径依赖类型:

onSuccess(api.GetEventsByDate(...): Future[api.Entities.EventsSearchResponse]) {
  value: api.Entities.EventsSearchResponse => ...
}

对此不确定,但通常当您出现“expected X,Get X”类型的类型错误时,这是因为X在Scala和Java版本中是不同的类型。你试过检查你的java类导入吗?你能提供
jsonize
签名吗?@GabrielePetronella我已经添加了签名