我正在嘗試構建一個非常簡單的 api,通過 spring boot 連接到 astra Cassandra 節點資料庫。但是,即使我在 application.yml 中指定了鍵空間,它仍然會拋出例外:
com.datastax.oss.driver.api.core.servererrors.InvalidQueryException: No keyspace has been specified. USE a keyspace, or explicitly specify keyspace.tablename
這是我的application.yml:
astra.api:
application-token: <my-token>
database-id: <my-db-id>
database-region: <my-db-region>
astra.cql:
enabled: true
downloadScb.path: secure-connect.zip
spring.data.cassandra:
keyspace-name: shopping_list
schema-action: CREATE_IF_NOT_EXISTS
我也嘗試過使用keyspace而不是keyspace-name,并將其放在 astra.api 甚至 astra.cql 下。但是,這些都不起作用。
我完全按照本教程進行操作,但我無法弄清楚問題所在。
我檢查了令牌、資料庫 ID 和資料庫區域都正確,并且安全連接包也在那里。應用程式確實可以從 application.yml 中獲取其他值,例如 scb 路徑和模式操作,但顯然不是鍵空間名稱。
非常感謝您的任何意見!
uj5u.com熱心網友回復:
( astra-spring-boot-starterwith all key astra.*) 將初始化CqlSession以及 Astra 所需的任何連接(Cassandra、Rest APIs、gRPC、pulsar ......)。
Spring Data Casandra 檢測到連接并使用它。您可以使用下面的 Cassandra 驅動程式的任何配置密鑰driver-config。
application.yaml應該看起來像。
astra:
api:
application-token: <your_token>
database-id: <your_db_id>
database-region: <your_db_region>
cql:
enabled: true
download-scb:
enabled: true
driver-config:
basic:
session-keyspace: <your_keyspace>
啟動器檔案 https://github.com/datastax/astra-sdk-java/wiki/Spring-Boot-Starter-Quickstart#4-configuration
示例作業專案(mvc、rest、cassandra、Oauth2、thymeleaf) https://github.com/datastaxdevs/workshop-betterreads
轉載請註明出處,本文鏈接:https://www.uj5u.com/caozuo/481297.html
標籤:爪哇 弹簧靴 卡桑德拉 datastax-astra
