首页 > 编程语言 >解决报错:Java 8 date/time type `java.time.Duration` not supported by default: add Module "com.faste

解决报错:Java 8 date/time type `java.time.Duration` not supported by default: add Module "com.faste

时间:2022-12-20 18:22:28浏览次数:48  
标签:jackson datatype jsr310 time com fasterxml

1、错误信息:

Java 8 date/time type java.time.Duration not supported by default: add Module "com.fasterxml.jackson.datatype:jackson-datatype-jsr310" to enable handling

2、解决办法:

implementation 'com.fasterxml.jackson.datatype:jackson-datatype-jsr310:2.14.1'

3、加上下面两个注解:

// 解决报错 : Java 8 date/time type `java.time.Duration` not supported by default: add Module "com.fasterxml.jackson.datatype:jackson-datatype-jsr310" to enable handling
@JsonDeserialize(using = LocalDateTimeDeserializer.class)
@JsonSerialize(using = LocalDateTimeSerializer.class)
private LocalDateTime createTime;

标签:jackson,datatype,jsr310,time,com,fasterxml
From: https://www.cnblogs.com/qbbit/p/16994846.html

相关文章