Bladeren bron

Long精度丢失

wangwl 2 weken geleden
bovenliggende
commit
61fdf20b7f

+ 5 - 1
leromro-framework/src/main/java/com/leromro/framework/config/ApplicationConfig.java

@@ -1,6 +1,8 @@
 package com.leromro.framework.config;
 
 import java.util.TimeZone;
+
+import com.fasterxml.jackson.databind.ser.std.ToStringSerializer;
 import org.mybatis.spring.annotation.MapperScan;
 import org.springframework.boot.autoconfigure.jackson.Jackson2ObjectMapperBuilderCustomizer;
 import org.springframework.context.annotation.Bean;
@@ -25,6 +27,8 @@ public class ApplicationConfig
     @Bean
     public Jackson2ObjectMapperBuilderCustomizer jacksonObjectMapperCustomization()
     {
-        return jacksonObjectMapperBuilder -> jacksonObjectMapperBuilder.timeZone(TimeZone.getDefault());
+        return jacksonObjectMapperBuilder -> jacksonObjectMapperBuilder.timeZone(TimeZone.getDefault())
+                .serializerByType(Long.class, new ToStringSerializer())
+                .serializerByType(Long.TYPE, new ToStringSerializer());
     }
 }