에러 

org.springframework.web.util.NestedServletException: Request processing failed; nested exception is org.springframework.http.converter.HttpMessageConversionException: Type definition error: [simple type, class com.example.model.City]; nested exception is com.fasterxml.jackson.databind.exc.InvalidDefinitionException: Cannot construct instance of `com.example.model.City` (no Creators, like default construct, exist): cannot deserialize from Object value (no delegate- or property-based Creator)

 at [Source: (PushbackInputStream); line: 2, column: 3]

 


생성자에 Jackson의 @JsonCreator를 붙여 해결하고 싶겠지만. 결국 문제가 발생할 것이다. 




 @Data

public class City {

@NonNull

private Long id;


@NonNull

private String name;


@NonNull

private Integer population;


@JsonCreator

public City(Long id, String name, Integer population) {

this.id = id;

this.name = name;

this.population =  population;

}

}


 

아래 org.springframework.web.HttpMediaTypeNotSupportedException 이 발생하게 된다...

https://knight76.tistory.com/entry/orgspringframeworkwebHttpMediaTypeNotSupportedException-%ED%95%B4%EA%B2%B0%ED%95%98%EA%B8%B0


최대한 Lombok을 잘 사용하는 것이 좋다. 

Posted by 김용환 '김용환'

댓글을 달아 주세요