List of usage examples for org.springframework.http.converter.json Jackson2ObjectMapperBuilder configure
public void configure(ObjectMapper objectMapper)
From source file:nu.yona.server.CoreConfiguration.java
@Bean @Primary/*from w w w .j av a 2s.co m*/ ObjectMapper objectMapper() { // HATEOAS disables the default Spring configuration options described at // https://docs.spring.io/spring-boot/docs/current/reference/html/howto-spring-mvc.html#howto-customize-the-jackson-objectmapper // See https://github.com/spring-projects/spring-hateoas/issues/333. // We fix this by applying the Spring configurator on the HATEOAS object mapper // See also // https://github.com/spring-projects/spring-boot/blob/v1.3.2.RELEASE/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/hateoas/HypermediaAutoConfiguration.java // which already seems to do this but does not work ObjectMapper springHateoasObjectMapper = beanFactory.getBean(SPRING_HATEOAS_OBJECT_MAPPER, ObjectMapper.class); Jackson2ObjectMapperBuilder builder = beanFactory.getBean(Jackson2ObjectMapperBuilder.class); builder.configure(springHateoasObjectMapper); // By default, Jackson converts dates to UTC. This causes issues when passing inactivity creation requests from the app // service to the analysis engine service. springHateoasObjectMapper.disable(DeserializationFeature.ADJUST_DATES_TO_CONTEXT_TIME_ZONE); // This way, the JsonView annotations on the controlers work properly springHateoasObjectMapper.enable(MapperFeature.DEFAULT_VIEW_INCLUSION); return springHateoasObjectMapper; }