您可以使用
@JsonUnwrapped链接
用于指示属性应“未包装”序列化的注释;也就是说,如果将其序列化为JSON对象,则其属性将作为其包含对象的属性包含在内。
样例代码:
@Entitypublic class Users{ @Id @Column(name = "user_id") @JsonProperty("userId") private int id; @JsonUnwrapped @ManyToOne @JoinColumn("city_id") private City city; // other fields, getters, setters}


