gpt4 book ai didi

java - 找不到请求的操作的编解码器 : [date <-> java. util.Date]

转载 作者:塔克拉玛干 更新时间:2023-11-03 05:20:10 24 4
gpt4 key购买 nike

在 Cassandra 中,列类型设置为日期,在模型类中,字段类型设置为 java.util.Date,带有 getter 和 setter。在 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());

关于java - 找不到请求的操作的编解码器 : [date <-> java. util.Date],我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/41480481/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com