com.fasterxml.jackson.databind.exc.invaliddefinitionException:不支持本地日期
我在尝试发送请求时收到此错误:
com.fasterxml.jackson.databind.exc.InvalidDefinitionException:Java 8 默认情况下不支持日期/时间类型“java.time.LocalDate”:添加 模块“com.fasterxml.jackson.datatype:jackson-datatype-jsr310” 启用处理
我也添加了依赖项并尝试将其注册为:
@Bean
public ObjectMapper objectMapper() {
ObjectMapper mapper = new ObjectMapper();
mapper.registerModule(new JavaTimeModule());
return mapper;
}
尽管它仍然给出相同的错误。我不想在实体属性上添加注释,因为它们是从开放 API 生成的源。有什么建议来解决这个问题吗?
I am getting this error when trying to send a request:
com.fasterxml.jackson.databind.exc.InvalidDefinitionException: Java 8
date/time type `java.time.LocalDate` not supported by default: add
Module "com.fasterxml.jackson.datatype:jackson-datatype-jsr310" to
enable handling
I have added the dependency as well and tried to register it with:
@Bean
public ObjectMapper objectMapper() {
ObjectMapper mapper = new ObjectMapper();
mapper.registerModule(new JavaTimeModule());
return mapper;
}
Though it still giving the same error. I don't want to add notations on the entity properties because they are generated sources from an Open API. Any suggestions to solve this problem?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论