I am using Springboot 2.0.6 and for some reason, the app yml changes did not work. And also I had more requirements.
I tried creating ObjectMapper and marking it as Primary but spring boot complained that I already have jacksonObjectMapper as marked Primary!!
So this is what I did. I made changes to the internal mapper.
My Serializer and Deserializer are special - they deal with 'dd/MM/YYYY'; and while de-serializing - it tries its best to use 3-4 popular format to make sure I have some LocalDate.
@Autowired ObjectMapper mapper; @PostConstruct public ObjectMapper configureMapper() { mapper.setSerializationInclusion(JsonInclude.Include.NON_NULL); mapper.enable(DeserializationFeature.ACCEPT_EMPTY_STRING_AS_NULL_OBJECT); mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false); mapper.configure(SerializationFeature.ORDER_MAP_ENTRIES_BY_KEYS, true); mapper.configure(MapperFeature.ALLOW_COERCION_OF_SCALARS, true); mapper.configure(MapperFeature.SORT_PROPERTIES_ALPHABETICALLY, true); SimpleModule module = new SimpleModule(); module.addDeserializer(LocalDate.class, new LocalDateDeserializer()); module.addSerializer(LocalDate.class, new LocalDateSerializer()); mapper.registerModule(module); return mapper; }