ashutoshsahoo / gs-spring-boot-cassandra

Spring Boot 3 with Cassandra NoSQL Database

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Spring Boot + Apache Cassandra

$ docker compose up -d
  • Open Cassandra CQL Shell:
$ docker compose exec -it cassandra-node1 /bin/bash
$ cqlsh -u cassandra -p password123
  • Create Cassandra keyspace with name customer_ks:
cqlsh> CREATE KEYSPACE customer_ks WITH replication={'class':'SimpleStrategy', 'replication_factor':1};
  • Create customer table in customer_ks keyspace:
cqlsh> USE customer_ks;
cqlsh:customer_ks> CREATE TABLE customer(id int PRIMARY KEY,firstname text,lastname text,age int);
  • Create an index on firstname column:
cqlsh:customer_ks> CREATE INDEX ON customer_ks.customer (firstname);
  • Verify and Query customer table:
cqlsh:customer_ks> DESCRIBE TABLE customer;
cqlsh:customer_ks> SELECT * FROM customer;
  • Run the application:
$ gradle bootRun

About

Spring Boot 3 with Cassandra NoSQL Database


Languages

Language:Java 100.0%