配置Jackson3时区

master
RuoYi 2 weeks ago
parent 2bf47dc87c
commit 4816246e0b

@ -1,9 +1,8 @@
package com.ruoyi.common.security.config; package com.ruoyi.common.security.config;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.databind.json.JsonMapper;
import java.util.TimeZone; import java.util.TimeZone;
import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Bean;
import tools.jackson.databind.json.JsonMapper.Builder;
/** /**
* 系统配置 * 系统配置
@ -16,11 +15,8 @@ public class ApplicationConfig
* 时区配置 * 时区配置
*/ */
@Bean @Bean
public ObjectMapper objectMapper() public tools.jackson.databind.json.JsonMapper jacksonJsonMapper(Builder builder)
{ {
ObjectMapper objectMapper = JsonMapper.builder().build(); return builder.defaultTimeZone(TimeZone.getTimeZone("GMT+8")).build();
objectMapper.findAndRegisterModules();
objectMapper.setTimeZone(TimeZone.getDefault());
return objectMapper;
} }
} }

Loading…
Cancel
Save