fix: Jackson 时区固定为 GMT+8,避免时间字段早 8 小时
容器 JVM 默认时区可能是 UTC,customizer 用 TimeZone.getDefault() 会覆盖
spring.jackson.time-zone,导致 java.util.Date(创建时间、登录时间等)
序列化后比实际早 8 小时,页面出现凌晨时间。
Co-Authored-By: Claude Code <noreply@anthropic.com>
| | |
| | | */ |
| | | @Bean |
| | | public Jackson2ObjectMapperBuilderCustomizer jacksonObjectMapperCustomization() { |
| | | return jacksonObjectMapperBuilder -> jacksonObjectMapperBuilder.timeZone(TimeZone.getDefault()); |
| | | // 固定东八区:容器/服务器 JVM 默认时区可能是 UTC, |
| | | // 若用 TimeZone.getDefault() 会覆盖 spring.jackson.time-zone, |
| | | // 导致 java.util.Date(创建时间、登录时间等)序列化后早 8 小时。 |
| | | return jacksonObjectMapperBuilder -> |
| | | jacksonObjectMapperBuilder.timeZone(TimeZone.getTimeZone("GMT+8")); |
| | | } |
| | | |
| | | @Bean |