how to Fix spring boot one to many bidirectional infinity loop?

后端 未结 3 1357
被撕碎了的回忆
被撕碎了的回忆 2021-01-20 00:45

i am try to create a one to many bidirectional mapping using spring boot and spring data jpa please look the below entity

Employer Entity

3条回答
  •  遥遥无期
    2021-01-20 01:17

    Instead of using @JsonBackReferenceand @JsonManagedReference try to use annotation @JsonIgnoreProperties:

    @JsonIgnoreProperties("employer")
    private List employees;  
    
    @JsonIgnoreProperties("employees")
    private Employer employer;  
    

    It prevents Jackson from rendering a specified properties of associated objects.

提交回复
热议问题