feat: 任务开始页面,相关逻辑补充
This commit is contained in:
@@ -1,10 +1,12 @@
|
||||
package com.guo.learningprogresstracker.config;
|
||||
|
||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||
import com.fasterxml.jackson.databind.SerializationFeature;
|
||||
import com.fasterxml.jackson.databind.module.SimpleModule;
|
||||
import com.guo.learningprogresstracker.config.serializer.LocalDateTimeSerializer;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.http.converter.json.Jackson2ObjectMapperBuilder;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
@@ -14,11 +16,17 @@ import java.time.LocalDateTime;
|
||||
@Configuration
|
||||
public class JacksonConfig {
|
||||
@Bean
|
||||
public ObjectMapper objectMapper() {
|
||||
ObjectMapper mapper = new ObjectMapper();
|
||||
public ObjectMapper objectMapper(Jackson2ObjectMapperBuilder builder) {
|
||||
ObjectMapper mapper = builder.build();
|
||||
|
||||
// 注册自定义序列化器
|
||||
SimpleModule module = new SimpleModule();
|
||||
module.addSerializer(LocalDateTime.class, new LocalDateTimeSerializer());
|
||||
mapper.registerModule(module);
|
||||
|
||||
// 关闭序列化为时间戳(使用字符串格式)
|
||||
mapper.disable(SerializationFeature.WRITE_DATES_AS_TIMESTAMPS);
|
||||
|
||||
return mapper;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user