@JsonIgnore注解
作用:在json序列化時將pojo中的一些屬性忽略掉,標記在屬性或者方法上,返回的json數據即不包含該屬性。
@Table(name = "tb_user") public class User { @Id @GeneratedValue(strategy = GenerationType.IDENTITY) private Long id; private String username;// 用戶名 @JsonIgnore private String password;// 密碼 private String phone;// 電話 private Date created;// 創建時間 @JsonIgnore private String salt;// 密碼的鹽值 //TODO add getter setters }