JAXB Mapping cyclic references to XML

后端 未结 5 881
醉酒成梦
醉酒成梦 2020-11-27 05:38

I have an object graph that contains a cycle. How do I get JAXB to handle this? I tried using the @XmlTransient annotation in the child class but the JAXB mar

5条回答
  •  长情又很酷
    2020-11-27 06:28

    XMLTransient almost always works for cycles. It might be a possibility that you have XMLTransient on the field level but you have not specified XMLAccessorType to be XmlAccessType.Field. If you don't specify anything the default is XmlAccessType.Property - or your getters. I have experienced Jaxb picking xml elements from getters from a class that I missed the accessor type annotations on and still work perfectly fine.

提交回复
热议问题