From 0646f39d5e7d7e4bf47b27f985e89a336c1927ad Mon Sep 17 00:00:00 2001 From: oyo Date: Mon, 26 Jan 2026 19:51:19 +0800 Subject: [PATCH] =?UTF-8?q?=E5=A2=9E=E5=8A=A0bigDecimalModule?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../common/response/ObjectMapperFactory.java | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/template/common/src/main/java/{{.packagePath}}/common/response/ObjectMapperFactory.java b/template/common/src/main/java/{{.packagePath}}/common/response/ObjectMapperFactory.java index 8f5f586..8148569 100644 --- a/template/common/src/main/java/{{.packagePath}}/common/response/ObjectMapperFactory.java +++ b/template/common/src/main/java/{{.packagePath}}/common/response/ObjectMapperFactory.java @@ -5,6 +5,8 @@ import com.fasterxml.jackson.core.JsonParser.Feature; import com.fasterxml.jackson.databind.DeserializationFeature; import com.fasterxml.jackson.databind.ObjectMapper; import com.fasterxml.jackson.databind.SerializationFeature; +import com.fasterxml.jackson.databind.ser.std.ToStringSerializer; +import java.math.BigDecimal; public class ObjectMapperFactory { private static final ObjectMapper objectMapper = new ObjectMapper(); @@ -18,6 +20,9 @@ public class ObjectMapperFactory { static { objectMapper.disable(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES).disable(SerializationFeature.FAIL_ON_EMPTY_BEANS).disable(SerializationFeature.WRITE_DATES_AS_TIMESTAMPS).configure(Feature.ALLOW_SINGLE_QUOTES, true); + SimpleModule bigDecimalModule = new SimpleModule(); + bigDecimalModule.addSerializer(BigDecimal.class, new ToStringSerializer()); + objectMapper.registerModule(bigDecimalModule); objectMapper.setDateFormat(new MyDateFormat()); } } \ No newline at end of file