今天看了很多例子,结果发现目前的系统Spring Boot 1.5.8,只能靠实现 Jackson2ObjectMapperBuilderCustomizer 来解决个例Object序列话输出问题,主要是在RestTemplate中加载上新的module。
@Configuration
public class JasksonConfig {
private final MoneySerializer moneySerializer = new MoneySerializer();
@Bean
public Jackson2ObjectMapperBuilderCustomizer addCustomBigDecimalDeserialization() {
return builder -> {
builder.serializerByType(MonetaryAmount.class, moneySerializer); //your module
builder.indentOutput(true); // 一定要开启
};
}
}
网友评论