39 lines
1.3 KiB
Java
39 lines
1.3 KiB
Java
|
|
package com.zhgd.config;
|
|||
|
|
|
|||
|
|
import org.springframework.context.annotation.Configuration;
|
|||
|
|
|
|||
|
|
/**
|
|||
|
|
* @program: wisdomSite
|
|||
|
|
* @description:
|
|||
|
|
* @author: Mr.Peng
|
|||
|
|
* @create: 2021-12-16 15:15
|
|||
|
|
**/
|
|||
|
|
@Configuration
|
|||
|
|
public class HttpMessageConvertConfig {
|
|||
|
|
|
|||
|
|
/**
|
|||
|
|
*
|
|||
|
|
* @param builder
|
|||
|
|
* @return
|
|||
|
|
*/
|
|||
|
|
/*@Bean
|
|||
|
|
public ObjectMapper jacksonObjectMapper(Jackson2ObjectMapperBuilder builder) {
|
|||
|
|
ObjectMapper objectMapper = builder.createXmlMapper(false).build();
|
|||
|
|
objectMapper.setDateFormat(new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"));
|
|||
|
|
objectMapper.setTimeZone(TimeZone.getTimeZone("GMT+8"));
|
|||
|
|
// 排序key
|
|||
|
|
objectMapper.configure(SerializationFeature.ORDER_MAP_ENTRIES_BY_KEYS, true);
|
|||
|
|
//忽略空bean转json错误
|
|||
|
|
objectMapper.configure(SerializationFeature.FAIL_ON_EMPTY_BEANS, false);
|
|||
|
|
//忽略在json字符串中存在,在java类中不存在字段,防止错误。
|
|||
|
|
objectMapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
|
|||
|
|
|
|||
|
|
|
|||
|
|
SimpleModule simpleModule = new SimpleModule();
|
|||
|
|
simpleModule.addSerializer(Long.class, ToStringSerializer.instance);
|
|||
|
|
simpleModule.addSerializer(Long.TYPE, ToStringSerializer.instance);
|
|||
|
|
objectMapper.registerModule(simpleModule);
|
|||
|
|
return objectMapper;
|
|||
|
|
}*/
|
|||
|
|
}
|