Jackson
[Spring] ObjectMapper -> Jackson2ObjectMapperBuilder vs 생성자
1. 기본생성자가 없는 객체에 대한 역직렬화 차이여기 객체 1개가 있다.@Getter@AllArgsConstructorpublic class TestDto { private String id;} 기본생성자가 없는 객체를 만들었다. 직렬화/역직렬화 테스트를 해보자.@RestControllerpublic class TestController { @GetMapping public TestDto test(@RequestBody TestDto dto) { return dto; }}// input{ "id": "1"}// output{ "id": "1"}문제 없이 성공한다. 성공하는 이유는 JacksonHttpMessageConvertersConfiguration 클래스..
[Spring] jackson 역직렬화, 필드가 1개일 때 HttpMessageNotReadableException
jackson 2.17 문제 상황개발환경java 21spring 3.3.0jackson 2.17.1 다음과 같은 java 코드가 있다.@RestControllerpublic class TestController { @GetMapping public TestDto test(@RequestBody TestDto dto) { return dto; }}@Getter@AllArgsConstructorpublic class TestDto { private String id;} 1. TestDto는 필드가 1개 & 기본 생성자 없이 전체 생성자만 갖고 있다.2. 컨트롤러에서는 필드가 1개인 TestDto를 @RequestBody로 역직렬화해야 한다. HttpMessageNotRead..