Commit ae917438a078afb9dfa9dafaa161634dcd516bf4
1 parent
baf37162
Long转json精度丢失的配置 未生效issues/I49DNI
同步钉钉人员到本地错误 #2990
Showing
3 changed files
with
14 additions
and
14 deletions
jeecg-boot/jeecg-boot-base/jeecg-boot-base-core/src/main/java/org/jeecg/config/WebMvcConfiguration.java
... | ... | @@ -5,11 +5,12 @@ import com.fasterxml.jackson.databind.module.SimpleModule; |
5 | 5 | import com.fasterxml.jackson.databind.ser.std.ToStringSerializer; |
6 | 6 | import org.springframework.beans.factory.annotation.Value; |
7 | 7 | import org.springframework.boot.actuate.trace.http.InMemoryHttpTraceRepository; |
8 | +import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean; | |
8 | 9 | import org.springframework.context.annotation.Bean; |
9 | 10 | import org.springframework.context.annotation.Conditional; |
10 | 11 | import org.springframework.context.annotation.Configuration; |
11 | -import org.springframework.http.converter.HttpMessageConverter; | |
12 | -import org.springframework.http.converter.json.MappingJackson2HttpMessageConverter; | |
12 | +import org.springframework.context.annotation.Primary; | |
13 | +import org.springframework.http.converter.json.Jackson2ObjectMapperBuilder; | |
13 | 14 | import org.springframework.web.cors.CorsConfiguration; |
14 | 15 | import org.springframework.web.cors.UrlBasedCorsConfigurationSource; |
15 | 16 | import org.springframework.web.filter.CorsFilter; |
... | ... | @@ -17,8 +18,6 @@ import org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry |
17 | 18 | import org.springframework.web.servlet.config.annotation.ViewControllerRegistry; |
18 | 19 | import org.springframework.web.servlet.config.annotation.WebMvcConfigurer; |
19 | 20 | |
20 | -import java.util.List; | |
21 | - | |
22 | 21 | /** |
23 | 22 | * Spring Boot 2.0 解决跨域问题 |
24 | 23 | * |
... | ... | @@ -71,20 +70,21 @@ public class WebMvcConfiguration implements WebMvcConfigurer { |
71 | 70 | return new CorsFilter(urlBasedCorsConfigurationSource); |
72 | 71 | } |
73 | 72 | |
73 | + | |
74 | 74 | /** |
75 | - * 添加Long转json精度丢失的配置 | |
76 | - * @Return: void | |
77 | - */ | |
78 | - @Override | |
79 | - public void configureMessageConverters(List<HttpMessageConverter<?>> converters) { | |
80 | - MappingJackson2HttpMessageConverter jackson2HttpMessageConverter = new MappingJackson2HttpMessageConverter(); | |
75 | + * 序列换成json时,将所有的long变成string | |
76 | + * js中long过长精度丢失 | |
77 | + */ | |
78 | + @Bean | |
79 | + @Primary | |
80 | + @ConditionalOnMissingBean(ObjectMapper.class) | |
81 | + public ObjectMapper jacksonObjectMapper(Jackson2ObjectMapperBuilder builder) { | |
81 | 82 | ObjectMapper objectMapper = new ObjectMapper(); |
82 | 83 | SimpleModule simpleModule = new SimpleModule(); |
83 | 84 | simpleModule.addSerializer(Long.class, ToStringSerializer.instance); |
84 | 85 | simpleModule.addSerializer(Long.TYPE, ToStringSerializer.instance); |
85 | 86 | objectMapper.registerModule(simpleModule); |
86 | - jackson2HttpMessageConverter.setObjectMapper(objectMapper); | |
87 | - converters.add(jackson2HttpMessageConverter); | |
87 | + return objectMapper; | |
88 | 88 | } |
89 | 89 | |
90 | 90 | /** |
... | ... |
jeecg-boot/jeecg-boot-module-system/pom.xml
jeecg-boot/pom.xml
... | ... | @@ -19,7 +19,7 @@ |
19 | 19 | <spring-cloud.version>Hoxton.SR8</spring-cloud.version> |
20 | 20 | <spring-cloud-alibaba.version>2.2.3.RELEASE</spring-cloud-alibaba.version> |
21 | 21 | <xxl-job-core.version>2.2.0</xxl-job-core.version> |
22 | - <fastjson.version>1.2.76</fastjson.version> | |
22 | + <fastjson.version>1.2.78</fastjson.version> | |
23 | 23 | <knife4j-spring-boot-starter.version>2.0.9</knife4j-spring-boot-starter.version> |
24 | 24 | <knife4j-spring-ui.version>2.0.9</knife4j-spring-ui.version> |
25 | 25 | <!-- 数据库驱动 --> |
... | ... |