From 103b9534b4c7aa54b028c5e2b24e8a8e733cb2d9 Mon Sep 17 00:00:00 2001 From: YunaiV Date: Fri, 26 Jun 2026 16:57:04 -0700 Subject: [PATCH 1/2] =?UTF-8?q?fix=EF=BC=9Ahttp-client-type:=20HttpCompone?= =?UTF-8?q?nts=20=E6=B3=A8=E9=87=8A=E9=94=99=E8=AF=AF=E7=9A=84=E9=97=AE?= =?UTF-8?q?=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../src/main/resources/application-dev.yaml | 2 +- .../src/main/resources/application-local.yaml | 2 +- yudao-server/src/main/resources/application-dev.yaml | 2 +- yudao-server/src/main/resources/application-local.yaml | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/yudao-module-system/yudao-module-system-server/src/main/resources/application-dev.yaml b/yudao-module-system/yudao-module-system-server/src/main/resources/application-dev.yaml index a6b3de940..28b362e6b 100644 --- a/yudao-module-system/yudao-module-system-server/src/main/resources/application-dev.yaml +++ b/yudao-module-system/yudao-module-system-server/src/main/resources/application-dev.yaml @@ -152,7 +152,7 @@ wx: config-storage: type: RedisTemplate # 采用 RedisTemplate 操作 Redis,会自动从 Spring 中获取 key-prefix: wa # Redis Key 的前缀 - http-client-type: HttpComponents # 采用 HttpComponents(HttpClient 5)请求微信公众号平台 + http-client-type: HttpComponents # 采用 HttpComponents(HttpClient 5)请求微信小程序平台 --- #################### 芋道相关配置 #################### diff --git a/yudao-module-system/yudao-module-system-server/src/main/resources/application-local.yaml b/yudao-module-system/yudao-module-system-server/src/main/resources/application-local.yaml index a6c793582..31c55ece9 100644 --- a/yudao-module-system/yudao-module-system-server/src/main/resources/application-local.yaml +++ b/yudao-module-system/yudao-module-system-server/src/main/resources/application-local.yaml @@ -173,7 +173,7 @@ wx: config-storage: type: RedisTemplate # 采用 RedisTemplate 操作 Redis,会自动从 Spring 中获取 key-prefix: wa # Redis Key 的前缀 - http-client-type: HttpComponents # 采用 HttpComponents(HttpClient 5)请求微信公众号平台 + http-client-type: HttpComponents # 采用 HttpComponents(HttpClient 5)请求微信小程序平台 --- #################### 芋道相关配置 #################### diff --git a/yudao-server/src/main/resources/application-dev.yaml b/yudao-server/src/main/resources/application-dev.yaml index faec8c7d1..4113d93df 100644 --- a/yudao-server/src/main/resources/application-dev.yaml +++ b/yudao-server/src/main/resources/application-dev.yaml @@ -142,7 +142,7 @@ wx: # 参见 https://github.com/Wechat-Group/WxJava/blob/develop/spring-boot-sta config-storage: type: RedisTemplate # 采用 RedisTemplate 操作 Redis,会自动从 Spring 中获取 key-prefix: wa # Redis Key 的前缀 - http-client-type: HttpComponents # 采用 HttpComponents(HttpClient 5)请求微信公众号平台 + http-client-type: HttpComponents # 采用 HttpComponents(HttpClient 5)请求微信小程序平台 --- #################### 芋道相关配置 #################### diff --git a/yudao-server/src/main/resources/application-local.yaml b/yudao-server/src/main/resources/application-local.yaml index 22f31c6cd..e2e24fb72 100644 --- a/yudao-server/src/main/resources/application-local.yaml +++ b/yudao-server/src/main/resources/application-local.yaml @@ -198,7 +198,7 @@ wx: config-storage: type: RedisTemplate # 采用 RedisTemplate 操作 Redis,会自动从 Spring 中获取 key-prefix: wa # Redis Key 的前缀 - http-client-type: HttpComponents # 采用 HttpComponents(HttpClient 5)请求微信公众号平台 + http-client-type: HttpComponents # 采用 HttpComponents(HttpClient 5)请求微信小程序平台 --- #################### 芋道相关配置 #################### From ac1ded1aafeb27cac3cdcdb6bcc970bee907e4f2 Mon Sep 17 00:00:00 2001 From: YunaiV Date: Fri, 26 Jun 2026 17:29:52 -0700 Subject: [PATCH 2/2] =?UTF-8?q?reactor=EF=BC=9A=E4=BC=98=E5=8C=96=20JsonUt?= =?UTF-8?q?ils=20=E7=9A=84=E7=BC=96=E7=A0=81=E9=A3=8E=E6=A0=BC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../framework/common/util/json/JsonUtils.java | 38 ++++++++++--------- 1 file changed, 21 insertions(+), 17 deletions(-) diff --git a/yudao-framework/yudao-common/src/main/java/cn/iocoder/yudao/framework/common/util/json/JsonUtils.java b/yudao-framework/yudao-common/src/main/java/cn/iocoder/yudao/framework/common/util/json/JsonUtils.java index 6bb1608d8..9452ff442 100644 --- a/yudao-framework/yudao-common/src/main/java/cn/iocoder/yudao/framework/common/util/json/JsonUtils.java +++ b/yudao-framework/yudao-common/src/main/java/cn/iocoder/yudao/framework/common/util/json/JsonUtils.java @@ -6,12 +6,14 @@ import cn.hutool.json.JSONUtil; import cn.iocoder.yudao.framework.common.util.json.databind.TimestampLocalDateTimeDeserializer; import cn.iocoder.yudao.framework.common.util.json.databind.TimestampLocalDateTimeSerializer; import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.core.JacksonException; import com.fasterxml.jackson.core.type.TypeReference; import com.fasterxml.jackson.databind.DeserializationFeature; import com.fasterxml.jackson.databind.JsonNode; import com.fasterxml.jackson.databind.ObjectMapper; import com.fasterxml.jackson.databind.SerializationFeature; import com.fasterxml.jackson.databind.module.SimpleModule; +import com.fasterxml.jackson.databind.json.JsonMapper; import com.fasterxml.jackson.datatype.jsr310.JavaTimeModule; import lombok.Getter; import lombok.SneakyThrows; @@ -33,17 +35,19 @@ import java.util.Map; public class JsonUtils { @Getter - private static ObjectMapper objectMapper = new ObjectMapper(); + private static ObjectMapper objectMapper = buildObjectMapper(); - static { - objectMapper.configure(SerializationFeature.FAIL_ON_EMPTY_BEANS, false); - objectMapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false); - objectMapper.setSerializationInclusion(JsonInclude.Include.NON_NULL); // 忽略 null 值 - // 解决 LocalDateTime 的序列化 + private static ObjectMapper buildObjectMapper() { SimpleModule simpleModule = new JavaTimeModule() + // 解决 LocalDateTime 的序列化 .addSerializer(LocalDateTime.class, TimestampLocalDateTimeSerializer.INSTANCE) .addDeserializer(LocalDateTime.class, TimestampLocalDateTimeDeserializer.INSTANCE); - objectMapper.registerModules(simpleModule); + return JsonMapper.builder() + .disable(SerializationFeature.FAIL_ON_EMPTY_BEANS) + .disable(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES) + .defaultPropertyInclusion(JsonInclude.Value.construct(JsonInclude.Include.NON_NULL, JsonInclude.Include.NON_NULL)) + .addModule(simpleModule) + .build(); } /** @@ -78,7 +82,7 @@ public class JsonUtils { } try { return objectMapper.readValue(text, clazz); - } catch (IOException e) { + } catch (JacksonException e) { log.error("json parse err,json:{}", text, e); throw new RuntimeException(e); } @@ -92,7 +96,7 @@ public class JsonUtils { JsonNode treeNode = objectMapper.readTree(text); JsonNode pathNode = treeNode.path(path); return objectMapper.readValue(pathNode.toString(), clazz); - } catch (IOException e) { + } catch (JacksonException e) { log.error("json parse err,json:{}", text, e); throw new RuntimeException(e); } @@ -104,7 +108,7 @@ public class JsonUtils { } try { return objectMapper.readValue(text, objectMapper.getTypeFactory().constructType(type)); - } catch (IOException e) { + } catch (JacksonException e) { log.error("json parse err,json:{}", text, e); throw new RuntimeException(e); } @@ -153,7 +157,7 @@ public class JsonUtils { public static T parseObject(String text, TypeReference typeReference) { try { return objectMapper.readValue(text, typeReference); - } catch (IOException e) { + } catch (JacksonException e) { log.error("json parse err,json:{}", text, e); throw new RuntimeException(e); } @@ -169,7 +173,7 @@ public class JsonUtils { public static T parseObjectQuietly(String text, TypeReference typeReference) { try { return objectMapper.readValue(text, typeReference); - } catch (IOException e) { + } catch (JacksonException e) { return null; } } @@ -186,7 +190,7 @@ public class JsonUtils { } try { return objectMapper.readValue(text, new TypeReference>() {}); - } catch (IOException e) { + } catch (JacksonException e) { return null; } } @@ -204,7 +208,7 @@ public class JsonUtils { } try { return objectMapper.readValue(text, clazz); - } catch (IOException e) { + } catch (JacksonException e) { return null; } } @@ -215,7 +219,7 @@ public class JsonUtils { } try { return objectMapper.readValue(text, objectMapper.getTypeFactory().constructCollectionType(List.class, clazz)); - } catch (IOException e) { + } catch (JacksonException e) { log.error("json parse err,json:{}", text, e); throw new RuntimeException(e); } @@ -229,7 +233,7 @@ public class JsonUtils { JsonNode treeNode = objectMapper.readTree(text); JsonNode pathNode = treeNode.path(path); return objectMapper.readValue(pathNode.toString(), objectMapper.getTypeFactory().constructCollectionType(List.class, clazz)); - } catch (IOException e) { + } catch (JacksonException e) { log.error("json parse err,json:{}", text, e); throw new RuntimeException(e); } @@ -238,7 +242,7 @@ public class JsonUtils { public static JsonNode parseTree(String text) { try { return objectMapper.readTree(text); - } catch (IOException e) { + } catch (JacksonException e) { log.error("json parse err,json:{}", text, e); throw new RuntimeException(e); }