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.
Comment From: philwebb
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.
Comment From: runabol
works like a charm. thanks!
Comment From: abccbaandy
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.
Comment From: sverhagen
A subtle variation of this problem, that certainly took me a lot of debugging, this tripped me up:
@EnableWebMvc
public class WebConfig implements WebMvcConfigurer {
...
I totally appreciate that the @EnableWebMvc wasn't necessary here, but hey, this is what I get for copy/pasting from Stack Overflow (in this case a quick solution to enable CORS).
Comment From: xuning888
In Spring Boot 1.5.8, I also encountered the same problem. May I inherit WebMvcConfigurerAdapter?
Comment From: philwebb
@xuning888 Spring Boot 1.5 is no longer supported, please upgrade to a recent version. If you have specific questions please ask on https://stackoverflow.com.