Resource HateOAS
408
작성한 질문수 2
Resource 부분에서 HateOAS가 보이지 않는데 어떤 오류일까요..?
POM.xml 에는 정상적으로 등록되어 있습니다..
답변 3
4
저는 스프링부트 2.4.12를 사용하고 있고, 처음에 Hateos 관련 클래스를 불러올 때 작성자님과 동일하게 고민했어서 도움이 되시길 바래서 강사님은 아니지만, 댓글 남깁니다.
Hateoas는 버전에 따라 사용하는 방법이 다르다고 알고있습니다.
제 코드입니다.
@GetMapping("/users/{id}")
public EntityModel<User> retrieveUser(@PathVariable int id){
Optional<User> user = userRepository.findById(id);
if(!user.isPresent()) {
throw new UserNotFoundException(String.format("ID[%S] not found", id));
}
EntityModel<User> 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/
해결이 안되셨다면 참고하시면 좋을 것 같아요!
3
버전문제로 이전강의 때 수정했던 내용 참조하여 아래와 같이 만들었습니다.
@GetMapping("/users/{id}")
public EntityModel<User> retrieveUser(@PathVariable int id) {
Optional<User> user = userRepository.findById(id);
if (!user.isPresent()) {
throw new UserNotFoundException(String.format("ID[%s] not found", id));
}
EntityModel<User> model = EntityModel.of(user.get());
WebMvcLinkBuilder linkTo = WebMvcLinkBuilder.linkTo(WebMvcLinkBuilder.methodOn(this.getClass()).retrieveAllUsers());
model.add(linkTo.withRel("all-users"));
return model;
}
JPA
0
63
1
jpa dependency를 추가하고 SecurityConfig클래스에서 오류가 납니다.
0
72
1
웹 브라우저 400 bad request
0
73
1
@Size는 되는데 @Past는 안 됩니다.
0
65
1
pdf 자료는 없나요?
0
76
2
locale 정보가 null 이면 무조건 messages_ko.properties이 호출 되는 문제
0
91
2
Swagger 강의, Unable to infer base url 이거 뜨시는 분들 도움되시라고
0
122
1
강의에서나온 화면 피피티
0
161
1
HelloWorldBean 관련 에러
0
189
2
Swagger API 3.x 오류..
0
223
1
java: variable message not initialized in the default constructor 에러는 어찌하면 좋을까요?
1
283
1
현재 GIT에 올리신 소스를 실행해봤습니다.
0
191
2
고양이 소리가 귀엽네요 !!
0
140
2
git에서 소스받고 실습중인데
0
120
1
post가 안되요
0
107
1
한국어 같은 경우 언어코드인 messages_ko.properties 로 생성하는게 더 좋지 않나요?
0
169
2
리턴타입으로서 EntityModel<User> 와 ResponseEntity질문
0
107
1
예외처리쪽 관련 질문있습니다.
0
161
2
엔티티가 바로 응답으로 나가도 되나요??
0
230
2
안녕하세여 Cannot invoke "co.kr.joneconsulting.resfulservice.repository.PostRepository.save(Object)" because "this.postRepository" is null
0
142
2
사용자 등록하고 나서 H2 에서 보면 신규 사용자의 password, ssn 이 null 로 되어 있습니다.
0
144
2
ApplictionContext 질문
0
196
2
롬북이 안먹히는것같아요
0
159
1
인텔리제이에서스프링부트 파일 실행하면
0
242
1





