Cassandra is a distributed, high-performance NoSQL database that stores rows in partitioned tables across multiple nodes. Replication can eliminate a single point of failure, while its eventually consistent model differs from relational databases. section 4.1
A Spring application can connect to Cassandra with a short setup sequence:
- Replace relational persistence dependencies with the nonreactive Spring Data Cassandra starter. section 4.1.1
- Start a Cassandra cluster, including a single-node Docker cluster for development. section 4.1.1
- Create a keyspace, the Cassandra grouping that contains tables, then configure its name and local datacenter. section 4.1.1
- Configure contact points, port, username, and password when connecting to a deployed cluster. section 4.1.1
Repository integration
Spring Data Cassandra repositories follow the familiar Spring Data pattern: declare an interface extending CrudRepository. An IngredientRepository can use String as its primary-key type, while an OrderRepository can use UUID. The repository is then ready to persist the corresponding domain objects with little implementation code. section 4.1.4
<dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-data-cassandra</artifactId> </dependency>
Inspect the Spring Boot dependency that activates Spring Data Cassandra and its repository autoconfiguration. section 4.1.1
