https://docs.spring.io/spring-restdocs/docs/3.0.0-SNAPSHOT/reference/htmlsingle/#documenting-your-api-query-parameters Spring REST Docs Document RESTful services by combining hand-written documentation with auto-generated snippets produced with Spring MVC Test or WebTestClient. docs.spring.io 이 글을 읽으면 더 자세하게 알 수 있다. 발생한 에러 해결방법 이유 Spring REST Docs는 MockMvc를 사용하여 API 요청을 모방하고 테스트하는데, MockMvc는 Spr..
문제 발생 평소 Rest Api를 이용했었는데 직접 @Controller를 사용해 구현하다가 발생함. 회원가입 버튼을 눌렀을 때, Controller에서 UserJoinRequestDto를 받고 처리하는데 받는 과정에서 발생한 에러다. 내가 구현한 View, Controller, Dto 회원가입 화면 join.html UserController UserJoinRequestDto 원인 Dto에 Setter가 존재하지 않으면 값을 설정할 수 없기 때문에 null이 발생한 것임. 해결 방법 Dto에 @Setter를 선언해서 해결 Js를 이용해 Api 통신 (Content-Type: application/json) Js를 제대로 이해하지 못하고 사용하는데 아직 불편해 @Setter를 사용했다. 정상적으로 값 들..
./gradlew test 를 했을 때 발생하는 문제. 처음 내가 작성했던 테스트 코드들을 살펴보자 import com.fasterxml.jackson.databind.ObjectMapper; import com.likelion.domain.entity.User; import com.likelion.domain.enums.UserRole; import com.likelion.domain.repository.UserRepository; import com.likelion.dto.user.UserJoinRequestDto; import com.likelion.dto.user.UserUpdateDto; import jakarta.persistence.EntityManager; import org.assertj..
이 코드의 목적 제목, 글쓴이, 제목 + 내용을 통한 게시글 검색 기능입니다. 이 오류는 왜 발생했을까? 먼저 QueryDSL을 작성한 코드를 보겠습니다. public Page search(PostSearchCondition condition, Pageable pageable) { List content = queryFactory .select(Projections.constructor(PostListResponseDto.class, post.id, user.id, user.nickname, post.thumbnail, post.title, post.content, post.hits, post.category, post.comment.size(), post.postLike.size(), post.crea..
Parameter value [1] did not match expected type 내가 만든 쿼리 유튜브 댓글처럼, 대댓글을 불러오기 위한 쿼리를 생성했다. 이 api를 호출했을 때, 부모 댓글을 기준으로 자식 댓글을 불러온다. 예외 발생 어.. 내가 원하는 값은 parentId를 기준으로 comment를 불러오는 건데 왜 예외가 발생하지? 예외 발생 원인 쿼리를 자세히 보자. c.parent 자체는 객체, parentId는 Long타입이기 때문에 바인딩이 안 돼서 발생한 예외다. Comment Entity를 살펴보자 되게 사소한 실수지만, 누구나 접할 수 있는 실수다. 올바른 쿼리로 바꾸기 정상 동작함을 알 수 있다!