找不到请求操作的编解码器:[date

前端之家收集整理的这篇文章主要介绍了找不到请求操作的编解码器:[date前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。

在Cassandra中,列类型设置为Date,而在Model类中,字段类型设置为带有getter和setter的java.util.Date.在com.datastax.driver.mapping.Mapper.save期间,我得到以下异常:

Codec not found for requested operation: [date <-> java.util.Date]

Caused by: com.datastax.driver.core.exceptions.CodecNotFoundException: Codec not found for requested operation: [date <-> java.util.Date]
at com.datastax.driver.core.exceptions.CodecNotFoundException.copy(CodecNotFoundException.java:56)
at com.datastax.driver.core.exceptions.CodecNotFoundException.copy(CodecNotFoundException.java:25)
at com.datastax.driver.mapping.DriverThrowables.propagateCause(DriverThrowables.java:41)
at com.datastax.driver.mapping.Mapper.save(Mapper.java:272)

在Google搜索期间找到以下内容

DATE      <-> com.datastax.driver.core.LocalDate : use getDate()
最佳答案
您必须将java.util.Date转换为com.datastax.driver.core.LocalDate

例:

 LocalDate localDate = LocalDate.fromMillisSinceEpoch(date.getTime());
原文链接:https://www.f2er.com/java/437372.html

猜你在找的Java相关文章