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