为什么我得到 "Application does not take parameters" 以及如何解决这个问题?

Why am I getting "Application does not take parameters" and how do I fix this?

@TravisBrown ,我工作得很好,但今天我试图将它改编为另一个例子,但在最后一行 ("Application does not take parameters") 出现了错误。我做错了什么?

请忽略 toString 方法,它们只是用于调试。

import play.api.libs.json._
import play.api.libs.functional.syntax._

sealed trait PressureUnit
case object HectoPascalsUnit extends PressureUnit  { override def toString(): String = "(HectoPascalsUnit)" }
case object InchesMercuryUnit extends PressureUnit { override def toString(): String = "(InchesMercuryUnit)" }

case class Pressure(value: Float, unit: PressureUnit)

class SeaLevelPressure(override val value: Float, override val unit: PressureUnit) extends Pressure(value, unit) {
  override def toString(): String = "(SeaLevelPressure value:"+value+" unit:"+unit+")"
}
class StationPressure(override val value: Float, override val unit: PressureUnit) extends Pressure(value, unit) {
  override def toString(): String = "(StationPressure value:"+value+" unit:"+unit+")"
}

object Pressure {
  implicit val pressureWrites: Writes[Pressure] = (
    (__ \ 'value).write[Int] and
      (__ \ 'unit).write[String].contramap[PressureUnit] {
        case HectoPascalsUnit => "hPa"
        case InchesMercuryUnit => "INS"
      }
    )(unlift(Pressure.unapply))  // Error: Application does not take parameters
}

我明白了。我需要改变这个:

(__ \ 'value.write[Int] and

对此:

(__ \ 'value.write[Float] and

抱歉打扰了!