我試圖避免使用spring-data-rest在JSON響應的內容中顯示幾個字段。註解@RestResource(exported = false)不適用於實體類中的屬性。這可能是一個類似的問題,到那個在報告:Property reference mapping in Spring Data Rest 2.0.0Spring Data Rest 2.0.0 - @RestResource(exported = false)不適用於屬性
在我的情況我有以下兩種屬性:
@RestResource(exported = false)
private byte[] image;
@RestResource(exported = false)
private Date updateTime;
註釋不工作。我也嘗試沒有成功的另一個方法:
@Override
protected void configureRepositoryRestConfiguration(RepositoryRestConfiguration config) {
config.setResourceMappingForDomainType(MyClass.class)
.addResourceMappingFor("updateTime")
.setExported(false);
}
在彈簧數據休息當前代碼展望github上讓我覺得,任何元數據(註釋)設置爲JSON對象是從未使用過的內容。感謝您對此問題的幫助。也許在當前的2.0.0版本中有不同的方式來做到這一點?
嘗試同時使用'@ RestResource'和'@ JsonIgnore'。它爲我工作。 – ElderMael