org.springframework.web.client.RestClientException: Error while extracting response for type

Dev.choi·2022년 3월 31일
0
post-thumbnail
org.springframework.web.client.RestClientException: Error while extracting response for type [class java.lang.Long] and content type [application/json]; nested exception is org.springframework.http.converter.HttpMessageNotReadableException: JSON parse error: Cannot deserialize value of type `java.lang.Long` from Object value (token `JsonToken.START_OBJECT`); nested exception is com.fasterxml.jackson.databind.exc.MismatchedInputException: Cannot deserialize value of type `java.lang.Long` from Object value (token `JsonToken.START_OBJECT`)
 at [Source: (org.springframework.util.StreamUtils$NonClosingInputStream); line: 1, column: 1]

PostsApiControllerTest Posts_수정된다() Run 돌리니까 위의 에러가 났다. 구글링의 해결책으로는 내 오류가 해결되지 않았다. 책 저자가 관련 메소드에서 Post를 Put으로 오타 실수가 있었다기에 혹시나하고 다음과 같이 수정하니 에러 해결.

✔️해결 전

ResponseEntity<Long> responseEntity = restTemplate.exchange(url, HttpMethod.PUT, requestEntity,Long.class);

✔️해결 후

ResponseEntity<Long> responseEntity = restTemplate.exchange(url, HttpMethod.PUT, requestEntity,Long.class);

📋참고자료

[실습문의] 110p.PostApiControllerTest 등록 테스트

profile
웹앱 공부 중입니다.

1개의 댓글

comment-user-thumbnail
2023년 1월 10일

수정 전 소스와 수정 후 소스가 차이가 없습니다.

답글 달기