更多内容请浏览本人博客
springboot 默认使用jackson解析,曾尝试更改默认解析为fastjson,但在集成某些框架时会有问题,
https://www.jianshu.com/p/0a2bf9165f68
根据官方文档,修改解析方式如下:
@Bean
public Jackson2ObjectMapperBuilderCustomizer customJackson() {
return jacksonObjectMapperBuilder -> {
jacksonObjectMapperBuilder.serializationInclusion(JsonInclude.Include.NON_NULL);
jacksonObjectMapperBuilder.failOnUnknownProperties(false);
jacksonObjectMapperBuilder.propertyNamingStrategy(PropertyNamingStrategy.SNAKE_CASE);
};
}
用配置文件的方法
在Spring的文档里面有(https://docs.spring.io/spring-boot/docs/current-SNAPSHOT/reference/htmlsingle/#howto-customize-the-jackson-objectmapper)