Spring-boot: Custom WebMvcConfiguration breaks Jackson formatting

Created on 4 Apr 2018  路  3Comments  路  Source: spring-projects/spring-boot

I'm using Spring Boot 2.0.0.RELEASE.

I have the following configuration to proxy some static content:

@Configuration
class WebMvcConfiguration extends WebMvcConfigurationSupport {

  @Value("${my.url}")
  private String myUrl;

  @Override
  protected void addResourceHandlers(ResourceHandlerRegistry aRegistry) {
    aRegistry.addResourceHandler("/some/path/**").addResourceLocations(myUrl);
  }
}

But that seems to break my Jackson config:

spring.jackson.date-format=yyyy-MM-dd'T'HH:mm:ss'Z'
spring.jackson.serialization.write-date-keys-as-timestamps=false

on my controllers. i.e. dates are coming as long timestamps as opposed to formatted.

invalid

Most helpful comment

Spring Boot is taking your use of WebMvcConfigurationSupport as an indication that it shouldn't auto-configure Spring MVC. Try replacing extends WebMvcConfigurationSupport with implements WebMvcConfigurer instead.

All 3 comments

Spring Boot is taking your use of WebMvcConfigurationSupport as an indication that it shouldn't auto-configure Spring MVC. Try replacing extends WebMvcConfigurationSupport with implements WebMvcConfigurer instead.

works like a charm. thanks!

This feature took me whole day to find out why my Jackson setting not work :(

Maybe we should add some doc in the class or some warning about it.

Was this page helpful?
0 / 5 - 0 ratings