Skip to content

daggerok/datastax-astra-db-spring-boot-app

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Spring Data Cassandra + DataStax Astra DB

  • SignUp / SignIn in Datastax Astra to get your DB for free
  • Create datastax_astra_db_spring_boot_app_database database with datastax_astra_db_spring_boot_app_keyspace keyspace
  • Click connect on your database
  • Chose Java in Connect using a driver section
  • Click Download Bundle button and save zip archive as src/main/resources/secure-connect-datastax-astra-db-spring-boot-app-database.zip
  • Create token for Administrator User, grab your ClientID and ClisentSecret
  • Add src/main/resources/application-datastax.properties file with content:
    datastax.astra.secure-connect-bundle=/path/to/project/src/main/resources/secure-connect-datastax-astra-db-spring-boot-app-database.zip
    datastax.astra.client-id=$yourClientID
    datastax.astra.client-secret=$yourClientSecret
    datastax.astra.keyspace=datastax_astra_db_spring_boot_app_keyspace
  • Add dependency to your pom.xml file:
    <dependency>
      <groupId>com.datastax.oss</groupId>
      <artifactId>java-driver-core</artifactId>
      <version>4.13.0</version>
    </dependency>
  • Run app:
    mvn compile spring-boot:run
  • Post few messages and load them via rest api
    http :8080/api/v1/messages content=Hello,\ World\!
    http :8080/api/v1/messages content=Hello,\ again...
    http :8080/api/v1/messages
  • Done

RTFM