Could not write JSON: Infinite recursion (StackOverflowError); nested exception spring boot

前端 未结 7 1406
时光说笑
时光说笑 2020-12-08 23:18

This is my District Controller, when I try to fetch data after saving I get the error, even when I try get object form getDistrict(Long id) the same strikes ple

7条回答
  •  长情又很酷
    2020-12-08 23:47

    @JsonBackReference and @JsonManagedReference didn't work for me since I was using a class that represented a join table and the only way to get it to work was to put the @JsonBackReference above the fields representing the linked classes. The net effect was that if I was pulling a record from the join class using JSON, none of the join fields would show up, making the returned information useless.

    I'd give examples but I like to avoid long replies. @JsonIdentityInfo explained in the article below provides a short, simple but highly efficient solution.

    Bidirectional relationships and InfiniteRecursion

提交回复
热议问题