解决方式1:
对象字段(long类型)增加注解
@JsonSerialize(using = ToStringSerializer.class)
解决方式2:(推荐)
增加配置文件(全局)
@Configuration
public class SerialConfig {
@Bean
public ObjectMapper jacksonObjectMapper(Jackson2ObjectMapperBuilder builder) {
ObjectMapper objectMapper = builder.createXmlMapper(false).build();
SimpleModule simpleModule = new SimpleModule();
simpleModule.addSerializer(Long.class, ToStringSerializer.instance); // Long
simpleModule.addSerializer(Long.TYPE,ToStringSerializer.instance); // long
objectMapper.registerModule(simpleModule);
return objectMapper;
}
}
标签:long,java,simpleModule,Long,ToStringSerializer,class,objectMapper From: https://www.cnblogs.com/czyfsyt/p/17958157