1
我有以下情況下類:找不到隱格式參數
case class Customer(name: String)
也可以像這樣編碼:
class ServiceJsonProtocol extends DefaultJsonProtocol {
implicit val customerProtocol = jsonFormat1(Customer)
}
的問題是,這種代碼:
val route =
path("customer") {
post {
entity(as[Customer]) {
customer => complete {
customers.add(customer)
s"got customer with name ${customer.name}"
}
}
}
我得到這個:
could not find implicit value for parameter um: akka.http.scaladsl.unmarshalling.FromRequestUnmarshaller[Customer]
[error] entity(as[Customer]) {
問題是什麼?
如果您使用'spray-json',請在您的問題中提及它。另外,看看http://stackoverflow.com/questions/33574176/akka-http-could-not-find-implicit-value-for-parameter-unmarshalling – YoungSpice