SpringBoot中spring.jackson.date-format配置失效的解决办法
- 2019 年 12 月 11 日
- 筆記
通常在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 usinggetMessageConverters
fromWebMvcConfigurationSupport
.