使用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
提交
取消