通常在 springboot 中,关于 jackson 的配置如下:
spring.jackson.date-format=yyyy-MM-dd HH:mm:ss
spring.jackson.time-zone=GMT+8
spring.jackson.default-property-inclusion=non_null
spring.jackson.serialization.indent_output=false
如果发现 spring.jackson.date-format 失效,是因为 mvc 配置中加入了如下注解:
将其去掉即可!
SpringBoot 的文档中对其有说明:
Finally, if you opt out of the Spring Boot default MVC configuration by providing your own @EnableWebMvc configuration, you can take control completely and do everything manually by using getMessageConverters from WebMvcConfigurationSupport.