SceneryComment实体类 @Data @Entity @Table(name = 表名) @JsonInclude(JsonInclude.Include.NON_NULL) public class SceneryComment { @Id @GeneratedValue(strategy = GenerationType.IDENTITY) @JsonIgnore private Integer id; private Integer sceneryId; private String comment; private String picture; private Integer score; private Integer userId; private Date createData; @Transient private UserComment userComments = new UserComment(); UserComment实体类 @Data public class UserComment { private Integer id=1; private String headPortrait="http://pic37.nipic.com/20140113/8800276_184927469000_2.png"; private String userName="张三"; } Repository类 /** * 根据userid查所有数据 * @param userId * @return