BusinessTemplate.java
// ... @OneToMany(targetEntity = Link.class, mappedBy = "businessTemplate", fetch = FetchType.EAGER) private List<Link> links; // ...Link.java
//... @ManyToOne private BusinessTemplate businessTemplate; //...如果在LinkController中直接查询Link对象会出现json无限递归问题。
分别在父子类中添加如下注释: BusinessTemplate.java
@JsonIdentityInfo(generator = ObjectIdGenerators.PropertyGenerator.class, property = "id") public class BusinessTemplate { //... }Link.java
@JsonIdentityInfo(generator = ObjectIdGenerators.PropertyGenerator.class, property = "id") public class Link { //... }Jackson – Bidirectional Relationships