|
|
@@ -8,6 +8,8 @@ import org.springframework.context.annotation.Bean;
|
|
|
import org.springframework.context.annotation.Configuration;
|
|
|
import org.springframework.context.annotation.Primary;
|
|
|
|
|
|
+import java.util.TimeZone;
|
|
|
+
|
|
|
@Configuration
|
|
|
public class JacksonConfig {
|
|
|
|
|
|
@@ -18,6 +20,8 @@ public class JacksonConfig {
|
|
|
mapper.setPropertyNamingStrategy(PropertyNamingStrategies.SNAKE_CASE);
|
|
|
mapper.registerModule(new JavaTimeModule());
|
|
|
mapper.disable(SerializationFeature.WRITE_DATES_AS_TIMESTAMPS);
|
|
|
+ // 固定序列化时区为北京时间,否则 OffsetDateTime 会被序列化为 UTC(Z),前端显示少8小时
|
|
|
+ mapper.setTimeZone(TimeZone.getTimeZone("Asia/Shanghai"));
|
|
|
return mapper;
|
|
|
}
|
|
|
}
|