내가 봄 데이터 REST는 "ID"및 "버전"없이 JSON을 반환하는 모든 파생 클래스의 기본 클래스스프링 데이터 REST는 기본적으로 JSON에서 기술 엔티티 필드 (@Version, @Id)를 숨 깁니다. 그것들을 평범한 속성으로 돌려 보내는 방법?
@MappedSuperclass
@Data //lombok annotation for getters/setter
public class BaseEntity implements Identifiable<Long> {
@Id @GeneratedValue(strategy = GenerationType.AUTO)
private Long id;
@Version
private Long version;
}
이 속성.
- 계획 : 나는이 개 솔루션을 발견했다.
다른 이름의 getter/setter를 추가
public Long getRevision() { return version; } public void setRevision(Long revision) { this.version = revision; } public Long getIdentifier() { return id; } public void setIdentifier(Long identifier) { this.id = identifier; }
두 솔루션은 해킹처럼 보인다. 더 나은 접근법이 존재합니까? 엔티티의 ID 표시가
노출 ID를 따르기는 하겠지만되고 [여기] 답변 (https://stackoverflow.com/q/34973156/5873923) [여기] (https://stackoverflow.com/q/24839760/5873923), [여기] (https://stackoverflow.com/q/24936636/5873923), [여기] (https://stackoverflow.com/q/30912826)/5873923) ... 노출되는 버전은 [여기] (https://stackoverflow.com/q/36853343/5873923)로 처리됩니다. –