参考方案

本文主要是翻译向,请善用google

在代码中的两个实体对象存在manytomany关系,如下:

public class PostEntity{

    @ManyToMany(fetch = FetchType.EAGER)
    @JoinTable(
            name = ""post_tag_relation"",
            joinColumns = @JoinColumn(name = ""post_id"",referencedColumnName = ""id""),
            inverseJoinColumns = @JoinColumn(name = ""tag_id"",referencedColumnName = ""id"")
    )
    private Set<TagEntity> tagEntities;
}
public class TagEntity extends AbstractAuditable {

    @ManyToMany(mappedBy = ""tagEntities"",fetch = FetchType.LAZY)
    private List<PostEntity> postEntityList;
}

在查询post实体时候,也会查询出关联的tag内容,使用spring boot自带的json序列化器jackson会报如下错误