SpringBoot中spring.jackson.date-format配置失效的解决办法

通常在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配置中加入了如下注解:

@EnableWebMvc

将其去掉即可!

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.

你可能感兴趣的:(SpringBoot中spring.jackson.date-format配置失效的解决办法)