GithubHelp home page GithubHelp logo

iamvickyav / spring-boot-with-cassandra Goto Github PK

View Code? Open in Web Editor NEW
0.0 2.0 0.0 8 KB

Simple Spring Boot Application with Cassandra DB

Groovy 100.00%
cassandra cassandra-java cqlsh spring spring-boot

spring-boot-with-cassandra's Introduction

SpringBoot with Cassandra

Running Cassandra in Local

To Install Cassandra in Mac

brew install Cassandra

To Start Cassandra

cassandra -f

To access Cassandra from Terminal

cqlsh

Getting Started with Cassandra

Creating Keyspace

CREATE KEYSPACE Sample WITH replication = {'class':'SimpleStrategy', 'replication_factor' : 1};

use Sample;

Creating Cassandra Table

CREATE TABLE Student(
    id int,
    name text,
    dept text,
    year_of_joining int,
    PRIMARY KEY (id)
);

CREATE TABLE Staff (
    id int, 
    name text,
    dept text,
    subjects list<text>, 
    PRIMARY KEY (id, dept)
);

Inserting sample data in Table

INSERT INTO Student (id, name, dept, year_of_joining) 
VALUES (1, 'Vicky', 'CSE', 2010);

INSERT INTO Staff (id, name, dept, subjects) 
VALUES (1, 'Selvam', 'CSE', ['Compiler Design', 'Operating System']);

Ok, now the DB is ready..! Lets start building the Spring Boot part

Go to https://start.spring.io & choose dependecies web, cassandra. Note: Don't chose JPA dependency when you use Cassandra.

In application.properties, give the keyspace name.

spring.data.cassandra.keyspace-name=Sample

Create your own Repo interface extending CassandraRepository

interface StudentRepo extends CassandraRepository<Student, Integer> {
}

spring-boot-with-cassandra's People

Contributors

iamvickyav avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.