zoukankan      html  css  js  c++  java
  • springboot2.x解决Long类型精度丢失问题

    直接新增一个类,重新启动即可:

    @JsonComponent
    public class JsonSerializerManage {
    
        @Bean
        public ObjectMapper jacksonObjectMapper(Jackson2ObjectMapperBuilder builder) {
            ObjectMapper objectMapper = builder.createXmlMapper(false).build();
            objectMapper.setSerializationInclusion(JsonInclude.Include.NON_NULL);
            SimpleModule module = new SimpleModule();
            module.addSerializer(Long.class, ToStringSerializer.instance);
            module.addSerializer(Long.TYPE, ToStringSerializer.instance);
            objectMapper.registerModule(module);
            return objectMapper;
        }
    }
  • 相关阅读:
    Day26
    Day25
    day24
    day22
    DAY21
    Day20
    Day19
    Day18
    Day17
    RabbitMQ
  • 原文地址:https://www.cnblogs.com/chenchaochao/p/12102436.html
Copyright © 2011-2022 走看看