1、繼承WebMvcConfigurationSupport實現自定義攔截器后,原先配置的時間格式返回變成時間戳,以下配置失效:
spring
jackson:
date-format: yyyy-MM-dd HH:mm:ss
time-zone: GMT+8
2、解決辦法不繼承WebMvcConfigurationSupport,修改為實現WebMvcConfigurer接口
@Configuration public class WebConfig implements WebMvcConfigurer { @Resource private JwtInterceptor jwtInterceptor; @Override public void addInterceptors(InterceptorRegistry registry) { registry.addInterceptor(jwtInterceptor) //攔截所有url .addPathPatterns("/**") //排除登錄url .excludePathPatterns("/", "/login"); } }
3、另外還有方式就是引入fastjson替換jackson。