[xingyu.guo] feat: 指定jackson对LocalDateTime的序列化规则
This commit is contained in:
@@ -0,0 +1,24 @@
|
||||
package com.guo.learningprogresstracker.config;
|
||||
|
||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||
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 java.time.LocalDateTime;
|
||||
|
||||
/**
|
||||
* @author guo
|
||||
*/
|
||||
@Configuration
|
||||
public class JacksonConfig {
|
||||
@Bean
|
||||
public ObjectMapper objectMapper() {
|
||||
ObjectMapper mapper = new ObjectMapper();
|
||||
SimpleModule module = new SimpleModule();
|
||||
module.addSerializer(LocalDateTime.class, new LocalDateTimeSerializer());
|
||||
mapper.registerModule(module);
|
||||
return mapper;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user