@Entity
@Inheritance(strategy = InheritanceType.SINGLE_TABLE)
public abstract class Criterion extends AbstractEntity {}
및 NameCriterion
는 그 서브 클래스
@Entity
public class NameCriterion extends Criterion {
private final String name;
}
스프링 데이터 REST는 t 그는 REST 자원으로 리포지토리 하나는 http://localhost:8080/api/criteria/에 액세스 할 수
다음과 같이수출 자원 같습니다
{
"_embedded": {
"nameCriteria": [{
"_links": {
"self": {
"href": "http://localhost:8080/api/nameCriterion/1"
},
"nameCriterion": {
"href": "http://localhost:8080/api/nameCriterion/1"
}
}
}
]
},
"_links": {
"self": {
"href": "http://localhost:8080/api/criteria"
},
"profile": {
"href": "http://localhost:8080/api/profile/criteria"
}
},
"page": {
"size": 20,
"totalElements": 1,
"totalPages": 1,
"number": 0
}
}
내가 자기 링크를 따라갈, http://localhost:8080/api/nameCriterion/1
의 매핑이없는 나는 따를 수 있습니다 http://localhost:8080/api/criteria/1하지만 내가 얻을 NameCriterion
{
"_links": {
"self": {
"href": "http://localhost:8080/api/nameCriterion/1"
},
"nameCriterion": {
"href": "http://localhost:8080/api/nameCriterion/1"
}
}
}
0에서
이름 필드없이 응답
집계 루트로 JpaRepository
에 사용 된 추상 클래스 Criterion
을 처리하기 위해 올바르게 조정되지 않은 REST 내보내기 프로그램에 정의 된 Jackson 매퍼에 문제가 있다고 가정합니다.
올바르게 작동시키기 위해 적용해야하는 Jackson 정의는 무엇입니까?
다른 말로하면 Jackson 모듈은 무엇을 만들어야합니까?
내 대답이 도움이 되었다면 그것을 수락하는 것을 잊지 마십시오!) – Cepr0