见:https://github.com/apache/incubator-streampark/pull/2583
该pr
把jackson
配置从代码更换到配置文件中,让使用的用户更改time-zone
时区、date-format
等变得更方便,因为很多海外用户,并不是使用咱们一个时区
将原来:
代码语言:javascript复制@Bean
public MappingJackson2HttpMessageConverter jackson2HttpMessageConverter() {
MappingJackson2HttpMessageConverter converter = new MappingJackson2HttpMessageConverter();
ObjectMapper mapper = new ObjectMapper();
mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
mapper.setDateFormat(new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"));
SimpleModule simpleModule = new SimpleModule();
simpleModule.addSerializer(Long.class, ToStringSerializer.instance);
simpleModule.addSerializer(Long.TYPE, ToStringSerializer.instance);
mapper.registerModule(simpleModule);
converter.setObjectMapper(mapper);
return converter;
}
改为:
代码语言:javascript复制@Bean
public Module jacksonModule() {
SimpleModule module = new SimpleModule();
module.addSerializer(Long.class, ToStringSerializer.instance);
module.addSerializer(Long.TYPE, ToStringSerializer.instance);
return module;
}
然后是配置文件
代码语言:javascript复制spring:
jackson:
date-format: yyyy-MM-dd HH:mm:ss
time-zone: GMT 8
deserialization:
fail-on-unknown-properties: false
mvc:
converters:
preferred-json-mapper: jackson