diff --git a/jeecg-boot/jeecg-boot-base/jeecg-boot-base-core/src/main/java/org/jeecg/config/WebMvcConfiguration.java b/jeecg-boot/jeecg-boot-base/jeecg-boot-base-core/src/main/java/org/jeecg/config/WebMvcConfiguration.java index 9b2689d..f7fe9bc 100644 --- a/jeecg-boot/jeecg-boot-base/jeecg-boot-base-core/src/main/java/org/jeecg/config/WebMvcConfiguration.java +++ b/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; import com.fasterxml.jackson.databind.ser.std.ToStringSerializer; import org.springframework.beans.factory.annotation.Value; import org.springframework.boot.actuate.trace.http.InMemoryHttpTraceRepository; +import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Conditional; import org.springframework.context.annotation.Configuration; -import org.springframework.http.converter.HttpMessageConverter; -import org.springframework.http.converter.json.MappingJackson2HttpMessageConverter; +import org.springframework.context.annotation.Primary; +import org.springframework.http.converter.json.Jackson2ObjectMapperBuilder; import org.springframework.web.cors.CorsConfiguration; import org.springframework.web.cors.UrlBasedCorsConfigurationSource; import org.springframework.web.filter.CorsFilter; @@ -17,8 +18,6 @@ import org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry import org.springframework.web.servlet.config.annotation.ViewControllerRegistry; import org.springframework.web.servlet.config.annotation.WebMvcConfigurer; -import java.util.List; - /** * Spring Boot 2.0 解决跨域问题 * @@ -71,20 +70,21 @@ public class WebMvcConfiguration implements WebMvcConfigurer { return new CorsFilter(urlBasedCorsConfigurationSource); } + /** - * 添加Long转json精度丢失的配置 - * @Return: void - */ - @Override - public void configureMessageConverters(List<HttpMessageConverter<?>> converters) { - MappingJackson2HttpMessageConverter jackson2HttpMessageConverter = new MappingJackson2HttpMessageConverter(); + * 序列换成json时,将所有的long变成string + * js中long过长精度丢失 + */ + @Bean + @Primary + @ConditionalOnMissingBean(ObjectMapper.class) + public ObjectMapper jacksonObjectMapper(Jackson2ObjectMapperBuilder builder) { ObjectMapper objectMapper = new ObjectMapper(); SimpleModule simpleModule = new SimpleModule(); simpleModule.addSerializer(Long.class, ToStringSerializer.instance); simpleModule.addSerializer(Long.TYPE, ToStringSerializer.instance); objectMapper.registerModule(simpleModule); - jackson2HttpMessageConverter.setObjectMapper(objectMapper); - converters.add(jackson2HttpMessageConverter); + return objectMapper; } /** diff --git a/jeecg-boot/jeecg-boot-module-system/pom.xml b/jeecg-boot/jeecg-boot-module-system/pom.xml index fee1d61..2e5a340 100644 --- a/jeecg-boot/jeecg-boot-module-system/pom.xml +++ b/jeecg-boot/jeecg-boot-module-system/pom.xml @@ -38,7 +38,7 @@ <dependency> <groupId>org.jeecgframework</groupId> <artifactId>jeewx-api</artifactId> - <version>1.4.5</version> + <version>1.4.6</version> <exclusions> <exclusion> <artifactId>commons-beanutils</artifactId> diff --git a/jeecg-boot/pom.xml b/jeecg-boot/pom.xml index 8870657..5b1dab0 100644 --- a/jeecg-boot/pom.xml +++ b/jeecg-boot/pom.xml @@ -19,7 +19,7 @@ <spring-cloud.version>Hoxton.SR8</spring-cloud.version> <spring-cloud-alibaba.version>2.2.3.RELEASE</spring-cloud-alibaba.version> <xxl-job-core.version>2.2.0</xxl-job-core.version> - <fastjson.version>1.2.76</fastjson.version> + <fastjson.version>1.2.78</fastjson.version> <knife4j-spring-boot-starter.version>2.0.9</knife4j-spring-boot-starter.version> <knife4j-spring-ui.version>2.0.9</knife4j-spring-ui.version> <!-- 数据库驱动 -->