diff --git a/pom.xml b/pom.xml index 249210a..41ca5ca 100644 --- a/pom.xml +++ b/pom.xml @@ -13,7 +13,7 @@ group.flyfish rest-proxy - 1.1.8 + 1.1.9 8 @@ -22,7 +22,7 @@ 1.8 4.4 2.6 - 1.1.8 + 1.1.9 pom diff --git a/rest-proxy-api/pom.xml b/rest-proxy-api/pom.xml index 7b51411..0414bc7 100644 --- a/rest-proxy-api/pom.xml +++ b/rest-proxy-api/pom.xml @@ -5,7 +5,7 @@ group.flyfish rest-proxy - 1.1.8 + 1.1.9 4.0.0 diff --git a/rest-proxy-core/pom.xml b/rest-proxy-core/pom.xml index ef428cd..467e566 100644 --- a/rest-proxy-core/pom.xml +++ b/rest-proxy-core/pom.xml @@ -5,7 +5,7 @@ group.flyfish rest-proxy - 1.1.8 + 1.1.9 4.0.0 diff --git a/rest-proxy-core/src/main/java/group/flyfish/rest/configuration/RestClientConfiguration.java b/rest-proxy-core/src/main/java/group/flyfish/rest/configuration/RestClientConfiguration.java index c7bd60f..5efc682 100644 --- a/rest-proxy-core/src/main/java/group/flyfish/rest/configuration/RestClientConfiguration.java +++ b/rest-proxy-core/src/main/java/group/flyfish/rest/configuration/RestClientConfiguration.java @@ -9,6 +9,7 @@ import group.flyfish.rest.registry.proxy.support.RestArgumentResolver; import group.flyfish.rest.registry.proxy.support.RestArgumentResolverComposite; import group.flyfish.rest.registry.proxy.support.resolvers.*; import group.flyfish.rest.utils.DataUtils; +import group.flyfish.rest.utils.JacksonUtil; import org.apache.http.impl.client.CloseableHttpClient; import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean; import org.springframework.boot.context.properties.ConfigurationProperties; @@ -90,4 +91,14 @@ public class RestClientConfiguration { ); return new RestArgumentResolverComposite(resolvers); } + + /** + * 更新原生的jackson object mapper + * + * @return 结果 + */ + @Bean + public JacksonUtil restJacksonUtil() { + return new JacksonUtil(); + } } diff --git a/rest-proxy-core/src/main/java/group/flyfish/rest/utils/JacksonUtil.java b/rest-proxy-core/src/main/java/group/flyfish/rest/utils/JacksonUtil.java index 5e8c1e1..714f264 100644 --- a/rest-proxy-core/src/main/java/group/flyfish/rest/utils/JacksonUtil.java +++ b/rest-proxy-core/src/main/java/group/flyfish/rest/utils/JacksonUtil.java @@ -9,6 +9,8 @@ import com.fasterxml.jackson.databind.DeserializationFeature; import com.fasterxml.jackson.databind.JavaType; import com.fasterxml.jackson.databind.ObjectMapper; import com.fasterxml.jackson.databind.SerializationFeature; +import org.springframework.beans.factory.ObjectProvider; +import org.springframework.beans.factory.annotation.Autowired; import java.io.IOException; import java.text.SimpleDateFormat; @@ -24,7 +26,7 @@ import java.util.Optional; */ public final class JacksonUtil { - private static final ObjectMapper mapper = new ObjectMapper(); + private static ObjectMapper mapper = new ObjectMapper(); static { // ========================================================================= @@ -64,6 +66,16 @@ public final class JacksonUtil { mapper.configure(JsonGenerator.Feature.ESCAPE_NON_ASCII, true); } + /** + * 修复不同环境下统一序列化表现 + * + * @param objectMappers jackson om + */ + @Autowired + public void setObjectMapper(ObjectProvider objectMappers) { + objectMappers.ifAvailable(om -> mapper = om); + } + public static T fromJson(final String json) { return readValue(json, new TypeReference() { });