0

我有以下代码

@XmlRootElement
@XmlSeeAlso(Array(classOf[EmailNotification],classOf[WebhookNotification]))
abstract class Notification {
}

@XmlRootElement
case class EmailNotification(@BeanProperty var recipients: JList[String],
                             @BeanProperty var subjectTemplate: String) extends Notification {
  def this() = this(new java.util.ArrayList[String](), null)
}

我正在尝试将notificationDetails字段从以下 json 反序列化为通知类型列表。

        "notificationDetails":["recipients":["a@b.com"], "subjectTemplate": "hmmm"}],

我收到以下错误

Caused by: org.codehaus.jackson.map.JsonMappingException: Can not construct instance of Notification, problem: abstract types can only be instantiated with additional type information at [Source: org.eclipse.jetty.server.HttpInput@4afa6dff; line: 1, column: 281] (through reference chain: Monitor["monitorRules"]->MonitorRules["notificationDetails"]) at org.codehaus.jackson.map.JsonMappingException.from(JsonMappingException.java:163) at org.codehaus.jackson.map.deser.StdDeserializationContext.instantiationException(StdDeserializationContext.java:233) ...

我的案例类是否缺少任何注释?

4

0 回答 0