Jackson with Spring MVC duplicate nested objects not deserializing

后端 未结 2 1714
庸人自扰
庸人自扰 2021-01-13 16:27

I am trying to Convert following POJO to a JSON in @RestController:

@Entity
@Table(name=\"user_location\")
@NamedQuery(name=\"UserLocation.findA         


        
2条回答
  •  孤独总比滥情好
    2021-01-13 16:58

    First remove that annotations from your State.java and City.java

    @JsonIdentityInfo(generator = ObjectIdGenerators.IntSequenceGenerator.class, property="@id", scope = State.class)
    
    @JsonIdentityInfo(generator = ObjectIdGenerators.IntSequenceGenerator.class, property="@id", scope = City.class)
    

    No need of these annotations and in RestController add return type as @ResponseBody UserLocation . It will give you json of that class.

提交回复
热议问题