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,11 +5,12 @@ import com.fasterxml.jackson.databind.module.SimpleModule; | ||
5 | import com.fasterxml.jackson.databind.ser.std.ToStringSerializer; | 5 | import com.fasterxml.jackson.databind.ser.std.ToStringSerializer; |
6 | import org.springframework.beans.factory.annotation.Value; | 6 | import org.springframework.beans.factory.annotation.Value; |
7 | import org.springframework.boot.actuate.trace.http.InMemoryHttpTraceRepository; | 7 | import org.springframework.boot.actuate.trace.http.InMemoryHttpTraceRepository; |
8 | +import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean; | ||
8 | import org.springframework.context.annotation.Bean; | 9 | import org.springframework.context.annotation.Bean; |
9 | import org.springframework.context.annotation.Conditional; | 10 | import org.springframework.context.annotation.Conditional; |
10 | import org.springframework.context.annotation.Configuration; | 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 | import org.springframework.web.cors.CorsConfiguration; | 14 | import org.springframework.web.cors.CorsConfiguration; |
14 | import org.springframework.web.cors.UrlBasedCorsConfigurationSource; | 15 | import org.springframework.web.cors.UrlBasedCorsConfigurationSource; |
15 | import org.springframework.web.filter.CorsFilter; | 16 | import org.springframework.web.filter.CorsFilter; |
@@ -17,8 +18,6 @@ import org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry | @@ -17,8 +18,6 @@ import org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry | ||
17 | import org.springframework.web.servlet.config.annotation.ViewControllerRegistry; | 18 | import org.springframework.web.servlet.config.annotation.ViewControllerRegistry; |
18 | import org.springframework.web.servlet.config.annotation.WebMvcConfigurer; | 19 | import org.springframework.web.servlet.config.annotation.WebMvcConfigurer; |
19 | 20 | ||
20 | -import java.util.List; | ||
21 | - | ||
22 | /** | 21 | /** |
23 | * Spring Boot 2.0 解决跨域问题 | 22 | * Spring Boot 2.0 解决跨域问题 |
24 | * | 23 | * |
@@ -71,20 +70,21 @@ public class WebMvcConfiguration implements WebMvcConfigurer { | @@ -71,20 +70,21 @@ public class WebMvcConfiguration implements WebMvcConfigurer { | ||
71 | return new CorsFilter(urlBasedCorsConfigurationSource); | 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 | ObjectMapper objectMapper = new ObjectMapper(); | 82 | ObjectMapper objectMapper = new ObjectMapper(); |
82 | SimpleModule simpleModule = new SimpleModule(); | 83 | SimpleModule simpleModule = new SimpleModule(); |
83 | simpleModule.addSerializer(Long.class, ToStringSerializer.instance); | 84 | simpleModule.addSerializer(Long.class, ToStringSerializer.instance); |
84 | simpleModule.addSerializer(Long.TYPE, ToStringSerializer.instance); | 85 | simpleModule.addSerializer(Long.TYPE, ToStringSerializer.instance); |
85 | objectMapper.registerModule(simpleModule); | 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
@@ -38,7 +38,7 @@ | @@ -38,7 +38,7 @@ | ||
38 | <dependency> | 38 | <dependency> |
39 | <groupId>org.jeecgframework</groupId> | 39 | <groupId>org.jeecgframework</groupId> |
40 | <artifactId>jeewx-api</artifactId> | 40 | <artifactId>jeewx-api</artifactId> |
41 | - <version>1.4.5</version> | 41 | + <version>1.4.6</version> |
42 | <exclusions> | 42 | <exclusions> |
43 | <exclusion> | 43 | <exclusion> |
44 | <artifactId>commons-beanutils</artifactId> | 44 | <artifactId>commons-beanutils</artifactId> |
jeecg-boot/pom.xml
@@ -19,7 +19,7 @@ | @@ -19,7 +19,7 @@ | ||
19 | <spring-cloud.version>Hoxton.SR8</spring-cloud.version> | 19 | <spring-cloud.version>Hoxton.SR8</spring-cloud.version> |
20 | <spring-cloud-alibaba.version>2.2.3.RELEASE</spring-cloud-alibaba.version> | 20 | <spring-cloud-alibaba.version>2.2.3.RELEASE</spring-cloud-alibaba.version> |
21 | <xxl-job-core.version>2.2.0</xxl-job-core.version> | 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 | <knife4j-spring-boot-starter.version>2.0.9</knife4j-spring-boot-starter.version> | 23 | <knife4j-spring-boot-starter.version>2.0.9</knife4j-spring-boot-starter.version> |
24 | <knife4j-spring-ui.version>2.0.9</knife4j-spring-ui.version> | 24 | <knife4j-spring-ui.version>2.0.9</knife4j-spring-ui.version> |
25 | <!-- 数据库驱动 --> | 25 | <!-- 数据库驱动 --> |