forest
forest copied to clipboard
反序列化offsetdatetime时失败
error:
json converter: 'ForestJacksonConverter' error: Java 8 date/time type java.time.OffsetDateTime not supported by default: add Module "com.fasterxml.jackson.datatype:jackson-datatype-jsr310" to enable handling
jackson默认不支持java8的时间类型,需要添加一个时间模块
<dependency>
<groupId>com.fasterxml.jackson.datatype</groupId>
<artifactId>jackson-datatype-jsr310</artifactId>
<version>2.13.3</version>
</dependency>
再通过@Bean方法定义 ForestJacksonConverter bean进行配置
@Bean
public ForestJsonConverter forestJacksonConverter() {
ForestJacksonConverter converter = new ForestJacksonConverter();
ObjectMapper mapper = converter.getMapper();
mapper.findAndRegisterModules();
return converter;
}