我是 Spring Boot 的初学者,无法解决问题。我有一个实体类 (Customer) 和一个 REST 存储库 (CustomerRepository)。该类包含一些我不希望 REST 存储库公开的敏感字段。因此,我使用 @JsonIgnore 注解对这些字段进行注解,如下所示:
package br.univali.sapi.entities;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.Inheritance;
import javax.persistence.InheritanceType;
import com.fasterxml.jackson.annotation.JsonIgnore;
@Entity
@Inheritance(strategy = InheritanceType.SINGLE_TABLE)
public class Customer
{
@Id
@GeneratedValue
private Long id = null;
private String login;
private String name;
@JsonIgnore
private String password;
@JsonIgnore
private String email;
public Customer()
{
}
public Long getId()
{
return id;
}
public void setId(Long id)
{
this.id = id;
}
public String getLogin()
{ …Run Code Online (Sandbox Code Playgroud)