diff --git a/pigx-common/pigx-common-core/pom.xml b/pigx-common/pigx-common-core/pom.xml
index d95b0daec..6006be1af 100644
--- a/pigx-common/pigx-common-core/pom.xml
+++ b/pigx-common/pigx-common-core/pom.xml
@@ -70,12 +70,17 @@
org.springframework.boot
spring-boot-starter-validation
-
com.fasterxml.jackson.module
- jackson-modules-java8
- ${jackson.modules}
- pom
+ jackson-module-parameter-names
+
+
+ com.fasterxml.jackson.datatype
+ jackson-datatype-jdk8
+
+
+ com.fasterxml.jackson.datatype
+ jackson-datatype-jsr310
diff --git a/pigx-common/pigx-common-core/src/main/java/com/pig4cloud/pigx/common/core/config/JacksonConfig.java b/pigx-common/pigx-common-core/src/main/java/com/pig4cloud/pigx/common/core/config/JacksonConfig.java
index f828857dd..eb2401d08 100644
--- a/pigx-common/pigx-common-core/src/main/java/com/pig4cloud/pigx/common/core/config/JacksonConfig.java
+++ b/pigx-common/pigx-common-core/src/main/java/com/pig4cloud/pigx/common/core/config/JacksonConfig.java
@@ -22,6 +22,9 @@ package com.pig4cloud.pigx.common.core.config;
import com.fasterxml.jackson.databind.DeserializationFeature;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.databind.SerializationFeature;
+import com.fasterxml.jackson.datatype.jdk8.Jdk8Module;
+import com.fasterxml.jackson.datatype.jsr310.JavaTimeModule;
+import com.fasterxml.jackson.module.paramnames.ParameterNamesModule;
import org.springframework.boot.autoconfigure.AutoConfigureBefore;
import org.springframework.boot.autoconfigure.condition.ConditionalOnClass;
import org.springframework.boot.autoconfigure.jackson.JacksonAutoConfiguration;
@@ -41,16 +44,16 @@ import org.springframework.http.converter.json.Jackson2ObjectMapperBuilder;
public class JacksonConfig {
/**
* 针对JDK 1.8 特殊处理
- * .registerModule(new ParameterNamesModule())
- * .registerModule(new Jdk8Module())
- * .registerModule(new JavaTimeModule()); // new module, NOT JSR310Module
*
* @return
*/
@Bean
public ObjectMapper getObjectMapper(Jackson2ObjectMapperBuilder builder) {
ObjectMapper objectMapper = builder.createXmlMapper(false).build();
- objectMapper.findAndRegisterModules();
+ ObjectMapper mapper = new ObjectMapper()
+ .registerModule(new ParameterNamesModule())
+ .registerModule(new Jdk8Module())
+ .registerModule(new JavaTimeModule()); // new module, NOT JSR310Module
// 忽略json字符串中不识别的属性
objectMapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
// 忽略无法转换的对象
diff --git a/pigx-config/src/main/resources/config/application-dev.yml b/pigx-config/src/main/resources/config/application-dev.yml
index 9f1e379b9..6ffd458a0 100644
--- a/pigx-config/src/main/resources/config/application-dev.yml
+++ b/pigx-config/src/main/resources/config/application-dev.yml
@@ -7,6 +7,10 @@ spring:
redis:
password:
host: redis
+ # Jackson配置
+ jackson:
+ time-zone: GMT+8
+ date-format: yyyy-MM-dd HH:mm:ss
# 暴露监控端点
management:
endpoints:
diff --git a/pigx-config/src/main/resources/config/pigx-codegen-dev.yml b/pigx-config/src/main/resources/config/pigx-codegen-dev.yml
index 133c73ab7..923770e6a 100644
--- a/pigx-config/src/main/resources/config/pigx-codegen-dev.yml
+++ b/pigx-config/src/main/resources/config/pigx-codegen-dev.yml
@@ -14,8 +14,5 @@ spring:
username: root
password: 123456
url: jdbc:mysql://mysql:3306/pigx?characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=false
- jackson:
- time-zone: GMT+8
- date-format: yyyy-MM-dd HH:mm:ss
resources:
static-locations: classpath:/static/,classpath:/views/
diff --git a/pom.xml b/pom.xml
index cfec5bc70..8f5ab5fcb 100644
--- a/pom.xml
+++ b/pom.xml
@@ -134,6 +134,14 @@
pom
import
+
+
+ com.fasterxml.jackson.module
+ jackson-modules-java8
+ ${jackson.modules}
+ pom
+ import
+