여기에서 묻는 질문과 똑같은 질문이 있습니다 (Exposing link on collection entity in spring data REST). 하지만이 주제의 어떤 것도 콜렉션 호출에 맞춤 링크를 추가하는 데 도움이되지 않습니다.스프링 hateoas를 사용하여 콜렉션 엔티티에 대한 링크가 노출되었습니다.
@Component
public class EventListResourceProcessor implements ResourceProcessor<Resources<Event>> {
@Autowired
private RepositoryEntityLinks entityLinks;
@Override
public Resources<Event> process(Resources<Event> events) {
events.add(entityLinks.linkToCollectionResource(Event.class).withRel("events"));
return events;
}
}
이 경우 프로세스 메서드가 호출되지 않습니다.
나는 _links 섹션에서 http://localhost:8080/event를 호출하고 my_custom_link 다음과 같은 JSON을 얻을 필요가 :
{
"_embedded": {
"event": [
{
"id": "1",
"name": "Updated event"
}]
},
"_links": {
"self": {
"href": "http://localhost:8080/event"
},
"profile": {
"href": "http://localhost:8080/profile/event"
},
"my_custom_link": {
"href": "http://localhost:8080/custom/"
}
},
"page": {
"size": 20,
"totalElements": 4,
"totalPages": 1,
"number": 0
}
}
}
당신이 내게 조언을 주시겠습니까?
미리 감사드립니다.