Test 코드 작성 및 GitHub Action에 적용을 위한 트러블 슈팅

song yuheon·2023년 9월 21일
0

Trouble Shooting

목록 보기
11/57
post-thumbnail

1. 트러블 슈팅

문제

JSON parse error: Cannot construct instance of `com.fanplayground.fanplayground.dto.UserUpdateRequestDto` (although at least one Creator exists): cannot deserialize from Object value (no delegate- or property-based Creator)]
  • 원인
    Spring에서 JSON 객체를 com.fanplayground.fanplayground.dto.UserUpdateRequestDto 클래스의 인스턴스로 변환하려 할 때, 해당 클래스에 JSON 객체의 값을 받아올 수 있는 적절한 생성자나 설정 메서드가 없음

  • 해결 방법
    Lombok 라이브러리에서 제공하는 @Builder@NoArgsConstructor 어노테이션을 함께 사용할 경우 위와 같은 오류가 발생할 수 있다.


2. 트러블 슈팅

문제: h2 testDB를 사용하여 GitHub action에서 빌드 오류 발생하였다.

  • 원인: GitHub action 환경에서는 localhost를 사용하는 h2 데이터베이스에 연결할 수 없다는 문제였음 ㅇㅅㅇ.

  • 해결 방법
    기존 설정에서 메모리 기반의 h2 데이터베이스 URL로 변경하여 문제를 해결했다.

    • 변경 전
      spring.datasource.url=jdbc:h2:tcp://localhost/~/trelloDB
    • 변경 후
      spring.datasource.url=jdbc:h2:mem:testdb;DB_CLOSE_DELAY=-1;DB_CLOSE_ON_EXIT=FALSE

결과



profile
backend_Devloper

0개의 댓글