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

gefangshuai · December 07, 2019 · 7190 hits

通常在 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.

No Reply at the moment.
You need to Sign in before reply, if you don't have an account, please Sign up first.