Angular 4 + Spring Boot + Cassandra CRUD example

In this tutorial, grokonez shows you Angular 4 Http Client & Spring Boot Server example that uses Spring Data to interact with Cassandra and Angular 4 as a front-end technology to make request and receive response.

Related Posts:
Angular 4 + Spring JPA + MySQL example | Angular 4 Http Client – Spring Boot RestApi Server
Angular 4 + Spring JPA + PostgreSQL example | Angular 4 Http Client – Spring Boot RestApi Server
Angular 4 + Spring JPA + MySQL example | Angular 4 Http Client – Spring Boot RestApi Server
Angular 4 + Spring Boot + MongoDB CRUD example
How to start Spring Data Cassandra with SpringBoot
Angular + Spring WebFlux + Spring Data Reactive Cassandra example | Full-Reactive Angular Http Client – Spring Boot RestApi Server

I. Technologies

– Java 1.8
– Maven 3.3.9
– Spring Tool Suite 3.9.0.RELEASE
– Spring Boot 1.5.9.RELEASE
– Angular 4
– Cassandra 3.9.0

II. Overview


1. Spring Boot Server


A Spring Boot Cassandra – example:
How to start Spring Data Cassandra with SpringBoot

2. Angular 4 Client

For more details:
– About Angular 4 Routing:
How to work with Angular Routing – Spring Boot + Angular 4
– About Angular Http Client to GET/POST/DELETE:
+ How to use Angular Http Client to fetch Data from SpringBoot RestAPI – Angular 4
+ How to use Angular HttpClient to POST, PUT, DELETE data on SpringBoot Rest APIs – Angular 4

III. Practice

1. Project Structure

1.1 Spring Boot Server


– Class Customer corresponds to customer table.
CustomerRepository is an interface extends Spring Data CassandraRepository, will be autowired in CustomerController for implementing repository methods and finder methods.
CustomerController is a REST Controller which has request mapping methods for RESTful requests such as: getAll, create, update, delete Customers.
– Configuration for Spring Data Cassandra properties in
– Dependencies for Spring Boot and Spring Data Cassandra in pom.xml

1.2 Angular 4 Client


In this example, we have:
– 3 components: customers-list, customer-details, create-customer.
– 3 modules: FormsModule, HttpClientModule, AppRoutingModule.
customer.ts: class Customer (id, name, age, active).
customer.service.ts: Service for HttpClient methods.

2. How to do

2.0 Set up Cassandra

Open Cassandra CQL Shell:

– Create Cassandra keyspace with name javasampleapproach:

– Create customer table for javasampleapproach keyspace:

2.1 Spring Boot Server
2.1.1 Dependency

2.1.2 Customer – Data Model

2.1.3 Repository

2.1.4 REST Controller

2.1.5 Configuration for Spring Data Cassandra

2.2 Angular 4 Client
2.2.1 AppModule

2.2.2 Model

2.2.3 DataService

2.2.4 Components

– CustomerDetailsComponent:

– CustomersListComponent:

– CreateCustomerComponent:

2.2.5 AppRoutingModule

2.2.6 App Component

3. Run & Check Result

Build and Run Spring Boot project with commandlines: mvn clean install and mvn spring-boot:run.
– Run the Angular App with command: npm start.

– Open browser for url http://localhost:4200/:
Add Customer(Jack,27):

Add more customers, check Cassandra table:

Choose tab Customers:

Update active status by click on Active label:

Delete a customer (Jack):

Check Cassandra table again, Katherin‘s active status has changed, and Jack data has been deleted:

Click Delete All button:

IV. Source Code


By grokonez | November 29, 2017.

Last updated on March 23, 2019.

Related Posts

2 thoughts on “Angular 4 + Spring Boot + Cassandra CRUD example”

Got Something To Say:

Your email address will not be published. Required fields are marked *