inflearn logo
강의

강의

N
챌린지

챌린지

멘토링

멘토링

N
클립

클립

로드맵

로드맵

지식공유

nina2439님의 게시글

nina2439 nina2439

@nina2439

수강평 작성수
-
평균평점
-

게시글 1

질문&답변

Resource HateOAS

저는 스프링부트 2.4.12를 사용하고 있고, 처음에 Hateos 관련 클래스를 불러올 때 작성자님과 동일하게 고민했어서 도움이 되시길 바래서 강사님은 아니지만, 댓글 남깁니다. Hateoas는 버전에 따라 사용하는 방법이 다르다고 알고있습니다. 제 코드입니다. @GetMapping("/users/{id}") public EntityModel retrieveUser(@PathVariable int id){ Optional user = userRepository.findById(id); if(!user.isPresent()) { throw new UserNotFoundException(String.format("ID[%S] not found", id)); } EntityModel userModel = new EntityModel (user.get()); WebMvcLinkBuilder linkTo = linkTo(methodOn(this.getClass()).retrieveAllUsers()); userModel.add(linkTo.withRel("all-users")); return userModel; } 제가 작성할 때 참고한 사이트는 다음과 같습니다. https://jeonghoon.netlify.app/Spring/SpringBoot13-hateoas/ 해결이 안되셨다면 참고하시면 좋을 것 같아요!

좋아요수
1
댓글수
3
조회수
414