【发布时间】:2016-12-11 03:48:17
【问题描述】:
在Hibernate-managed 实体中考虑这个属性:
@JsonFormat(pattern = "HH:mm")
@Column(name = "start_time")
private java.sql.Time startTime;
我将JSON-object 作为@RequestBody 发布到 Spring Controller,Jackson 应该映射到实体的实例 (pojo)。
Jackson 显然无法将时间字符串反序列化为java.sql.Time,因为我遇到了这个异常:
.w.s.m.s.DefaultHandlerExceptionResolver : Failed to read HTTP message:
org.springframework.http.converter.HttpMessageNotReadableException:
Could not read document: Can not construct instance of java.sql.Time,
problem: null
如何指导Jackson 了解该怎么做?
【问题讨论】:
标签: java json hibernate spring-mvc jackson