28 lines
979 B
Java
28 lines
979 B
Java
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;
|
|
|
|
@Configuration
|
|
public class JacksonConfig {
|
|
@Bean
|
|
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;
|
|
}
|
|
}
|