스프링부트 v3.x에서 json컬럼 사용시 custom objectMapper 적용

Created:

테스트 환경

  • springboot v3.2
  • hibernate 6.3.1

custom objectMapper 설정

@Configuration
public class ObjectMapperConfig {

    /**
     * custom objectMapper 생성
     */
    @Bean
    public ObjectMapper objectMapper() {
        ObjectMapper objectMapper = new ObjectMapper();
        objectMapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
        return objectMapper;
    }

    /**
     * custom objectMapper 설정
     */
    @Bean
    HibernatePropertiesCustomizer jsonFormatMapperCustomizer(ObjectMapper objectMapper) {
        return (properties) -> properties.put(MappingSettings.JSON_FORMAT_MAPPER, new JacksonJsonFormatMapper(objectMapper));
    }
}

참고

https://github.com/spring-projects/spring-boot/issues/33870

Comments