如果在yaml或properties中配置的这个
spring.jackson.date-format=yyyy-MM-dd HH:mm:ss
spring.jackson.time-zone=GMT+8
不生效
原因可能有:
- 继承了
WebMvcConfigurationSupport
这个类,并且@Configuration
加了这个注解,那么他就不用去使用 配置文件配置的jackson
而是用这个类中的配置,所以配置文件就会不起作用。 - @EnableWebMvc
解决
编写配置类
@Configuration
@EnableWebMvc
public class MvcConfig implements WebMvcConfigurer {
//解决 spring.jackson.date-f