在今天编码过程中发现一个小问题。
后端数据库数据:1169459812992421888
前台拿到:1169459812992422000
前几位高度重合,排除程序逻辑问题。
在返回前设置断点打印,数据依据与数据库依旧保持一致
说明数据是在返回过程中丢失了精度。
考虑不直接传Long,传json;
引入依赖
<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-annotations</artifactId>
<version>2.8.6</version>
</dependency>
<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-databind</artifactId>
<version>2.8.6</version>
</dependency>
在Long类型的值前面加上注解@JsonSerialize(using = ToStringSerializer.class)
即可解决