Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

反序列化offsetdatetime时失败 #98

Closed
oonxt opened this issue Jul 26, 2022 · 1 comment
Closed

反序列化offsetdatetime时失败 #98

oonxt opened this issue Jul 26, 2022 · 1 comment

Comments

@oonxt
Copy link

oonxt commented Jul 26, 2022

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

@mySingleLive
Copy link
Collaborator

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;
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants