Jackson HttpMessageNotReadableException:已经有了id的POJO

时间:2017-03-02 23:23:41

标签: jackson bidirectional

我不明白双向关系反序列化有什么问题:

序列化注册是:

{
uuid: "d3372f25-ac70-4735-b756-7894977142b2",
    payment: [{
        "uuid":"15363b3f-7057-4658-3f63-3f3f695d7019",
        "type":0,
        "amount":10
        "registration":"d3372f25-ac70-4735-b756-7894977142b2"
   },
   {
        "uuid":"ee9fb135-2b21-48f4-a1ee-2f71f09f44ab",
        "type":0,
        "amount":5
        "registration":"d3372f25-ac70-4735-b756-7894977142b2"
   }] 
}

Java是:

@JsonIdentityInfo(
    generator = ObjectIdGenerators.PropertyGenerator.class,
    property = "uuid", scope = Registration.class)
public class Registration implements Serializable {}

@JsonIdentityInfo(
    generator = ObjectIdGenerators.PropertyGenerator.class,
    property = "uuid", scope = Payment.class)
public class Payment implements Serializable {}
  

无法读取文件:已经有id的POJO(java.util.UUID)[[ObjectId:key = d3372f25-ac70-4735-b756-7894977142b2,type = com.fasterxml.jackson.databind.deser.impl。 PropertyBasedObjectIdGenerator,scope = com.mezoo.tdc.model.Registration]](通过引用链:com.mezoo.tdc.model.Registration [“payment”] - > java.util.ArrayList [0] - > com。 mezoo.tdc.model.Payment [ “注册”] - > com.mezoo.tdc.model.Registration [ “的uuid”]);嵌套异常是com.fasterxml.jackson.databind.JsonMappingException:已经有id的POJO(java.util.UUID)[[ObjectId:key = d3372f25-ac70-4735-b756-7894977142b2,type = com.fasterxml.jackson.databind .deser.impl.PropertyBasedObjectIdGenerator,scope = com.mezoo.tdc.model.Registration]](通过引用链:com.mezoo.tdc.model.Registration [“payment”] - > java.util.ArrayList [0] - > com.mezoo.tdc.model.Payment [ “注册”] - > com.mezoo.tdc.model.Registration [ “的uuid”])“

有人可以向我解释为什么反序列化不起作用吗?

0 个答案:

没有答案