Skip to main content

Documentation Index

Fetch the complete documentation index at: https://mintlify.com/spring-projects/spring-boot/llms.txt

Use this file to discover all available pages before exploring further.

Spring Data provides projects for a wide range of NoSQL technologies, and Spring Boot provides auto-configuration for the most commonly used ones. Adding the appropriate starter to your project gives you auto-configured connection factories, templates, and repository support out of the box — no boilerplate wiring required. Spring Boot provides auto-configuration for: Cassandra, Couchbase, Elasticsearch, LDAP, MongoDB, Neo4j, and Redis.
MongoDB is an open-source NoSQL document database that uses a JSON-like schema instead of traditional table-based relational data.Starter: spring-boot-starter-data-mongodbConnection configuration:
application.yaml
spring:
  mongodb:
    uri: "mongodb://user:secret@mongoserver1.example.com:27017,mongoserver2.example.com:23456/test"
Or using discrete properties:
application.yaml
spring:
  mongodb:
    host: "mongoserver1.example.com"
    port: 27017
    database: "test"
    username: "user"
    password: "secret"
Auto-configured beans: MongoDatabaseFactory, MongoTemplate, MongoClientRepository example:
CityRepository.java
public interface CityRepository extends MongoRepository<City, String> {

    List<City> findAllByState(String state);

    @Query("{ 'population': { $gt: ?0 } }")
    List<City> findCitiesWithPopulationGreaterThan(int population);
}
The domain class uses Spring Data MongoDB annotations:
City.java
@Document(collection = "cities")
public class City {

    @Id
    private String id;

    private String name;
    private String state;

    // constructors, getters, setters...
}
Spring Boot also provides spring-boot-starter-data-mongodb-reactive for reactive MongoDB applications using ReactiveMongoRepository and ReactiveMongoTemplate.
Redis is a cache, message broker, and richly-featured key-value store. Spring Boot offers auto-configuration for the Lettuce (default) and Jedis client libraries.Starter: spring-boot-starter-data-redisConnection configuration:
application.yaml
spring:
  data:
    redis:
      host: "localhost"
      port: 6379
      database: 0
      username: "user"
      password: "secret"
Or using a URL:
application.yaml
spring:
  data:
    redis:
      url: "redis://user:secret@localhost:6379"
      database: 0
Auto-configured beans: RedisConnectionFactory, StringRedisTemplate, RedisTemplateInject and use StringRedisTemplate directly:
MyBean.java
@Component
public class MyBean {

    private final StringRedisTemplate template;

    public MyBean(StringRedisTemplate template) {
        this.template = template;
    }

    public void store(String key, String value) {
        template.opsForValue().set(key, value);
    }

    public String retrieve(String key) {
        return template.opsForValue().get(key);
    }
}
Receiving messages with @RedisListener:
MyBean.java
@Component
public class MyBean {

    @RedisListener(topics = "someChannel")
    public void processMessage(String message) {
        // handle message
    }
}
Enable SSL for Redis connections:
application.yaml
spring:
  data:
    redis:
      ssl:
        enabled: true
Elasticsearch is an open source, distributed, RESTful search and analytics engine.Starter: spring-boot-starter-data-elasticsearchConnection configuration:
application.yaml
spring:
  elasticsearch:
    uris: "https://search.example.com:9200"
    socket-timeout: "10s"
    username: "user"
    password: "secret"
Spring Boot supports several clients:
  • Rest5Client (low-level REST client) — from co.elastic.clients:elasticsearch-rest5-client
  • ElasticsearchClient (Java API client) — from co.elastic.clients:elasticsearch-java
  • ReactiveElasticsearchClient — from org.springframework.data:spring-data-elasticsearch
Repository example:
CityRepository.java
public interface CityRepository extends ElasticsearchRepository<City, String> {

    List<City> findByState(String state);
}
Mark your domain class as an Elasticsearch document:
City.java
@Document(indexName = "cities")
public class City {

    @Id
    private String id;

    private String name;
    private String state;

    // constructors, getters, setters...
}
Enable sniffer for automatic node discovery:
application.yaml
spring:
  elasticsearch:
    restclient:
      sniffer:
        enabled: true
        interval: "10m"
        delay-after-failure: "30s"
Cassandra is an open source, distributed database management system designed to handle large amounts of data across many commodity servers.Starter: spring-boot-starter-data-cassandraConnection configuration:
application.yaml
spring:
  cassandra:
    keyspace-name: "mykeyspace"
    contact-points: "cassandrahost1:9042,cassandrahost2:9042"
    local-datacenter: "datacenter1"
Enable SSL:
application.yaml
spring:
  cassandra:
    keyspace-name: "mykeyspace"
    contact-points: "cassandrahost1,cassandrahost2"
    local-datacenter: "datacenter1"
    ssl:
      enabled: true
Auto-configured beans: CqlTemplate, CassandraTemplate, CqlSessionRepository example:
CityRepository.java
public interface CityRepository extends CassandraRepository<City, UUID> {

    @Query("SELECT * FROM city WHERE state = :state ALLOW FILTERING")
    List<City> findByState(@Param("state") String state);
}
Spring Data Cassandra repository support is more limited than JPA repositories and requires @Query-annotated finder methods for custom queries.
Couchbase is an open-source, distributed, multi-model NoSQL document-oriented database optimized for interactive applications.Starter: spring-boot-starter-data-couchbaseConnection configuration:
application.yaml
spring:
  couchbase:
    connection-string: "couchbase://192.168.1.123"
    username: "user"
    password: "secret"
  data:
    couchbase:
      bucket-name: "my-bucket"
Auto-configured beans: Cluster, CouchbaseTemplate, CouchbaseClientFactoryInject CouchbaseTemplate into your beans:
MyBean.java
@Component
public class MyBean {

    private final CouchbaseTemplate template;

    public MyBean(CouchbaseTemplate template) {
        this.template = template;
    }

    public City findCity(String id) {
        return template.findById(City.class).one(id);
    }
}
Configure connection timeouts and SSL with an SSL bundle:
application.yaml
spring:
  couchbase:
    env:
      timeouts:
        connect: "3s"
      ssl:
        bundle: "example"
Neo4j is an open-source NoSQL graph database that uses a rich data model of nodes connected by first-class relationships — better suited for highly-connected data than traditional RDBMS.Starter: spring-boot-starter-data-neo4jConnection configuration:
application.yaml
spring:
  neo4j:
    uri: "bolt://my-server:7687"
    authentication:
      username: "neo4j"
      password: "secret"
Auto-configured beans: Driver, Neo4jTemplate, ReactiveNeo4jTemplateDefine a node entity and repository:
City.java
@Node
public class City {

    @Id
    @GeneratedValue
    private Long id;

    private String name;
    private String state;

    // constructors, getters, setters...
}
CityRepository.java
public interface CityRepository extends Neo4jRepository<City, Long> {

    List<City> findAllByState(String state);
}
In an application using the reactive style, a ReactiveTransactionManager is not auto-configured. You must define a ReactiveNeo4jTransactionManager bean explicitly.
Spring Boot offers auto-configuration for any compliant LDAP server as well as support for the embedded in-memory LDAP server from UnboundID.Starter: spring-boot-starter-data-ldapConnection configuration:
application.yaml
spring:
  ldap:
    urls: "ldap://myserver:1235"
    username: "admin"
    password: "secret"
Auto-configured beans: LdapContextSource, LdapTemplateFor testing, use the embedded in-memory LDAP server:
application.yaml
spring:
  ldap:
    embedded:
      base-dn: "dc=spring,dc=io"
      ldif: "classpath:test-server.ldif"

Build docs developers (and LLMs) love