使用Spring 1.5.8.RELEASE Jackson映射器给出以下异常。Cannot deserialize value of type `java.util.Date` from String "2018-09-04T10:44:46": expected format "yyyy-MM-dd'T'HH:mm:ss.SSS"at [来源: 未知; 行: -1, 列: -1] (通过引用链: com.copart.conversationapi.calldisposition.model.vo.CallLogEntity[“callEndTime”])调用实体.java@JsonProperty("callEndTime")@Column(name = "call_end_ts")@JsonFormat(pattern="yyyy-MM-dd'T'HH:mm:ss.SSS")private Date callEndTime;道.javaObjectMapper mapper = new ObjectMapper();HashMap<String, Object> finalHashMap;finalHashMap = convertMultiToString(requestMap);mapper.enable(DeserializationFeature.ACCEPT_SINGLE_VALUE_AS_ARRAY);CallLogEntity callLogEntity = mapper.convertValue(finalHashMap, CallEntity.class);啪.xml<dependency> <groupId>com.fasterxml.jackson.core</groupId> <artifactId>jackson-databind</artifactId> <version>2.9.0</version> <exclusions> <exclusion> <groupId>com.fasterxml.jackson.core</groupId> <artifactId>jackson-core</artifactId> </exclusion> <exclusion> <groupId>com.fasterxml.jackson.core</groupId> <artifactId>jackson-annotations</artifactId> </exclusion> </exclusions> </dependency>
1 回答
郎朗坤
TA贡献1921条经验 获得超9个赞
将线路更改为此行。@JsonFormat
@JsonFormat(pattern="yyyy-MM-dd'T'HH:mm:ss")
您现在拥有的格式模式期望刺痛具有毫秒值 - 但您的示例字符串没有它们。
添加回答
举报
0/150
提交
取消