|
@@ -0,0 +1,29 @@
|
|
|
|
|
+package com.ytpm.question;
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+import com.ytpm.handle.MultiFormatDateDeserializer;
|
|
|
|
|
+import org.springframework.beans.factory.annotation.Value;
|
|
|
|
|
+import org.springframework.boot.autoconfigure.jackson.Jackson2ObjectMapperBuilderCustomizer;
|
|
|
|
|
+import org.springframework.context.annotation.Bean;
|
|
|
|
|
+import org.springframework.context.annotation.Configuration;
|
|
|
|
|
+
|
|
|
|
|
+import java.util.Date;
|
|
|
|
|
+
|
|
|
|
|
+/**
|
|
|
|
|
+ * @author lih
|
|
|
|
|
+ * @date 2025-10-15 10:22
|
|
|
|
|
+ */
|
|
|
|
|
+@Configuration
|
|
|
|
|
+public class JacksonConfig {
|
|
|
|
|
+
|
|
|
|
|
+ @Value("${spring.jackson.time-zone:Asia/Shanghai}")
|
|
|
|
|
+ private String timeZone;
|
|
|
|
|
+
|
|
|
|
|
+ @Bean
|
|
|
|
|
+ public Jackson2ObjectMapperBuilderCustomizer customJacksonConfig() {
|
|
|
|
|
+ return builder -> {
|
|
|
|
|
+ // 注册Date类型的序列化器和反序列化器
|
|
|
|
|
+ builder.deserializerByType(Date.class, new MultiFormatDateDeserializer(timeZone));
|
|
|
|
|
+ };
|
|
|
|
|
+ }
|
|
|
|
|
+}
|