spring - 为什么 Spring Cassandra 不将 @Table 中设置的值与 Scala 一起使用?
问题描述
我有以下代码...
@Table(keyspace = "ks", name="otherThing" )
class Thing extends Serializable{
...
}
然而当我跑...
repo.findAll()
我收到一个错误,看起来好像没有使用我提供的值...
询问; CQL [SELECT * FROM Thing;]; 未配置的表事物
我希望
Select * from ks.otherThing;
我错过了什么?
更新
我尝试转换为以下 Pojo
import com.datastax.driver.mapping.annotations.Table;
import org.springframework.data.cassandra.core.mapping.PrimaryKey;
@Table( keyspace="ks", name="otherThing" )
public class Thing implements Serializable {
...
}
我的回购很简单......
import org.springframework.stereotype.Repository;
@Repository
public interface ThingRepository extends CassandraRepository<Thing, ThingId> { }
但
thingRepo.findAll();
给...
询问; CQL [SELECT * FROM 事物;]; 未配置的表事物
解决方案
所以我犯的错误是试图通过使用我公司的 spring autoconfig 设置的连接来做到这一点。这使我可以通过application.properties
. 我注意到之前在那里声明了键空间,所以我回去将我的域对象更改为...
import org.springframework.data.cassandra.core.mapping.Table
@Table("otherThing" )
class Thing extends Serializable{
...
}
现在它正在工作。留下这个答案以防其他人感到困惑。
推荐阅读
- google-bigquery - BigQuery Weather 公共数据集 - 缺少最近几天的数据
- ios - Xcode 无法安装应用程序
- python - Localstack 和 AWS SQS 接收带有 boto3 的消息返回不同的消息格式
- javascript - 停止捕获(录制)后,iOS 13 无法播放音频(Web Audio API)
- spring - 将 spring 数据配置连接到 IBM DB2 z/os 时出现异常
- primefaces - PrimeFaces 日期选择器弹出窗口未显示
- r - 在不使用 ifelse() 的情况下,我们如何在 R 中创建 if 语句来评估逻辑值向量
- android - 有没有办法检查计时器是否正在使用 Timer Java 类运行?
- rust - 我得到了特征绑定`T:sns_pub::_IMPL_DESERIALIZE_FOR_Message::_serde::Serialize`不满意
- python - 如何从python中的字典中随机选择一定比例的键值对?