JAXB A cycle is detected in the object graph

后端 未结 4 811
说谎
说谎 2020-12-19 11:59

I want to convert my pojo to json with JAXB, my pojo have one to many relation, and when i convert my pojo to json, JAXB generate error \"A cycle is detected in the object g

4条回答
  •  -上瘾入骨i
    2020-12-19 12:37

    I faced similar problem when I wanted to convert my POJO to JSON with JaxRS. The MoxyJsonProvider is the default option of eclipselink but it fails to parse the JSOG (where cycles exists in the JSON structure). Jackson Jaxb Provider does this better with ObjectMapper.

    I have elaborated in this answer below, about how to invoke Jackson Provider instead of Moxy. You will need jackson packages in your pom xml.

    https://stackoverflow.com/a/60319306/5076414

提交回复
热议问题