Kaynağa Gözat

新增ObjectMapper组件配置

codingliang 1 yıl önce
ebeveyn
işleme
a512e0f07a

+ 19 - 0
src/main/java/com/sqx/config/JacksonConfiguration.java

@@ -0,0 +1,19 @@
+package com.sqx.config;
+
+import com.fasterxml.jackson.databind.DeserializationFeature;
+import com.fasterxml.jackson.databind.ObjectMapper;
+import org.springframework.context.annotation.Bean;
+import org.springframework.context.annotation.Configuration;
+
+@Configuration
+public class JacksonConfiguration {
+
+    @Bean
+    public ObjectMapper objectMapper() {
+        ObjectMapper mapper = new ObjectMapper();
+
+        mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
+
+        return mapper;
+    }
+}