HttpMediaTypeNotAcceptableException: Could not find acceptable representation
위와 같은 코드를 작성했고 이 Controller에서 DB 조회 후
MemberResponseDTO에 담아 보내게 되는 단순한 로직이다.
전에는 갑자기 잘 되던 api 가 ResponseDTO로 바꾸고 나서 잘 안 되길래
뭔가 싶더니
HttpMediaTypeNotAcceptableException라는 에러가 났다.
그래서 직접 에러를 검색해 보니,
클라이언트가 받을 수 있는 response를 만들 수 없다는 에러이다.
실제로 postman에서도 다음과 같은 에러가 나온다.
하지만 로그를 보면
즉, DB에 쿼리를 하는 과정까지는 문제가 아니었음을 알 수 있다.
그렇다면 쿼리를 하고 나서 클라이언트에게 올바를 형태를 주지 못한다는 것이고,
그래서 DTO를 봤더니 @Getter 가 없었다.
여러분은 꼭 @Getter 붙이시길 ㅠ
참고
"Could not find acceptable representation" using spring-boot-starter-web
I am trying to use spring-boot-starter-web to create a rest service serving up JSON representations of Java objects. From what I understand this boot-starter-web jar is supposed to handle the conve...
stackoverflow.com