• 카테고리

    질문 & 답변
  • 세부 분야

    백엔드

  • 해결 여부

    미해결

ResourceSupport대신 RepresentationModel 사용한경우..

20.04.09 07:56 작성 조회수 405

1

안녕하세요 강의 잘듣고있습니다.

앞에 강의에서 어떤분이 heteoas 버전이 변경되면서 바뀐부분이 있다고 알려주셔서 ResourceSupport대신 RepresentationModel 사용해서 따라하고 있었는데요.

assembler 에서 toResource 대신 toModel로 바뀌었다는 것까지는 알았습니다.

Consequently, ResourceAssembler has been renamed to RepresentationModelAssembler and its methods toResource(…) and toResources(…) have been renamed to toModel(…) and toCollectionModel(…) respectively. Also the name changes have been reflected in the classes contained in TypeReferences.

@GetMapping
public ResponseEntity queryEvents(Pageable pageable, PagedResourcesAssembler<Event> assembler){
Page<Event> page = this.eventRepository.findAll(pageable);
var resource = assembler.toModel(page, e-> new EventResource(e));
return ResponseEntity.ok(resource);
}

그런데 위와같이 하면 

Error:(66, 48) java: incompatible types: cannot infer functional interface descriptor for org.springframework.hateoas.server.RepresentationModelAssembler<com.hong.springrestapi.events.Event,org.springframework.hateoas.RepresentationModel>

이렇게 에러가 나는데 어떻게 해야할까요?

답변 2

·

답변을 작성해보세요.

1

솜솜님의 프로필

솜솜

2021.11.18

위 상황에 대한 저의 대처를 공유합니다.  

'이벤트 목록 조회 API 구현' 강의까지의 대처이며, 마지막 수업도 봤지만 버전업에 따른 라이브러리 변경이어서 참고가 되지 않았고 https://www.inflearn.com/questions/35748 로 가셔서 람다식 풀어쓴걸 가져오니  에러가 발생하지 않았습니다. 

 

1

스프링 HATEOAS API 변경 사항에 대해서는 마지막 수업을 참고해 주세요.