SpringBoot Reference
|
This section documents Spring Boot 4.1.x and Spring Framework 7.0.x on the Java 17/21+ baseline, as described by the official Spring Boot reference documentation and each sub-project’s own site (Spring Data, Spring for Apache Kafka, Micrometer, Project Reactor, springdoc-openapi, Spring gRPC, and the others listed in this section’s Bibliography) — which are the references these pages are written and verified against. This content was generated with the assistance of AI and should be verified against those official docs before being relied on in production. Spring Boot and its ecosystem continue to evolve; the examples here target the current 4.1.x / 7.0.x releases. This section’s bibliography lists the reference material consulted while preparing these pages. |
Welcome to the SpringBoot reference. Spring and Spring Boot are the dominant framework and application runtime for building Java backend services — dependency injection, externalized configuration, opinionated auto-configuration, and a vast, well-integrated ecosystem spanning data access, messaging, caching, and observability. This section documents the current Spring Boot 4.1.x / Spring Framework 7.0.x releases on the Java 17/21+ baseline, written and verified against docs.spring.io and each sub-project’s own site.
If you are new to Spring Boot, start with Getting Started, then Core Concepts and Configuration & Profiles, then work down the list or jump to what you need.
What’s covered
Getting started
-
Getting Started — what Spring and Spring Boot are, Spring Initializr, the Java 17/21+ baseline and Maven project layout,
@SpringBootApplication, running the app, and Spring Boot 2 → 3 → 4 migration notes.
Core concepts
-
Core Concepts — the IoC container, beans and dependency injection, component scanning,
@Configuration/@Bean, bean scopes and lifecycle callbacks, a short AOP note, and how auto-configuration resolves at startup. -
Core Annotations — what
@Component,@Service,@Repository,@Controller/@RestController, and@Configurationeach add beyond plain component scanning (persistence-exception translation, CGLIB proxying, web dispatch), plus a categorized reference table of every other core annotation used throughout this section. -
Java or Kotlin for Spring Boot? — first-class Kotlin support via the
kotlin-spring/kotlin-jpaplugins, a pros/cons comparison, a side-by-side REST endpoint, and guidance on which language to choose. -
Configuration & Profiles — externalized configuration and precedence,
@ConfigurationPropertiesvs.@Value, profiles, configuration metadata for IDE autocompletion, and runtime configuration changes with@RefreshScope(Spring Cloud Config + Bus, Kubernetes ConfigMaps/Secrets, AWS Secrets Manager/Parameter Store).
Spring Data
-
Spring Data Overview — the repository abstraction shared by every Spring Data module,
@Versionoptimistic locking, entity inheritance across stores, keyset scrolling withWindow<T>/ScrollPosition, and a map of which module to use for which database. -
Spring Data JPA (SQL) — entities and JPA mapping, entity inheritance (
@Inheritance/@MappedSuperclass),JpaRepository,@Query, Specifications/projections, transactions,@Versionoptimistic locking, auditing,Window<T>keyset scrolling, plus custom queries withJdbcClient/JdbcTemplate. -
Spring Data MongoDB —
MongoRepository, document mapping, polymorphic documents (@TypeAlias), indexes, auditing,@Versionoptimistic locking, transactions,Window<T>keyset scrolling, plus custom queries withMongoTemplate. -
Spring Data Couchbase —
CouchbaseRepository, N1QL/SQL queries, polymorphic documents, scopes/collections, `@Version`/CAS optimistic locking (no `Window<T>` keyset scrolling support -- see the SQL seek-query alternative), plus custom queries withCouchbaseTemplate. -
Spring Data Neo4j —
@Node/@Relationshipmapping, node inheritance via multiple labels,Neo4jRepository, Cypher queries, transactions,@Versionoptimistic locking, plus custom queries withNeo4jClient. -
Transaction Isolation & Locking — the
@Transactionalisolation attribute and its performance impact, pessimistic locking with@Lockand lock timeouts, and how it compares to@Versionoptimistic locking across the Spring Data stores.
ORM, search & batch
-
Hibernate (JPA & ORM) — the object/relational paradigm mismatch, the persistence context and entity lifecycle, lazy loading and the N+1 problem, first/second-level caching, HQL/JPQL/Criteria query options, and how
spring-boot-starter-data-jpawires Hibernate in as the default JPA provider. -
Elasticsearch — the inverted index, documents/indices/shards and replicas, analyzers and mappings, the query DSL and BM25 relevance, and Spring Boot + Spring Data Elasticsearch integration (
@Document,ElasticsearchRepository/ElasticsearchOperations, the Elasticsearch Java API Client); a dedicated reference section covers it in depth under Elasticsearch Reference. -
Apache Solr — cores and collections,
schema.xml/managed schema and analysis chains, request handlers and query parsers (DisMax/eDisMax), SolrCloud, and talking to Solr from Spring Boot via SolrJ now that Spring Data Solr is retired; a dedicated reference section covers it in depth under Apache Solr Reference. -
MongoDB Atlas Search — the $search/$searchMeta aggregation stages, search index definitions and per-language analyzers, fuzzy matching, faceting, and projection via stored source, compared with Elasticsearch and Apache Solr; a cloud-only Atlas service with no self-hosted equivalent — see MongoDB Reference: Text, wildcard, geospatial & Atlas search for the general Atlas Search/Vector Search outline.
-
Spring Batch — finite bulk processing: jobs and steps, chunk-oriented vs. tasklet steps, the
JobRepository, Spring Boot auto-configuration, and launching jobs. For the in-depth guide — fault tolerance, readers and writers, scaling and partitioning, observability and testing — see Spring Batch Reference.
Caching
-
Caching — the Spring Cache abstraction, local caching with Caffeine, and distributed caching with Redis.
-
Near-Far Caches — layering a local Caffeine near cache in front of a distributed Redis far cache: pros/cons versus a single tier, consistency and invalidation trade-offs, and Spring Boot implementation options (a custom composite
CacheManager, Redisson’sRLocalCachedMap).
File Storage
-
File Storage & Object Stores — why horizontally-scaled, ephemeral pod replicas can’t rely on local/container disk, network-mounted filesystems (Amazon EFS, Google Cloud Filestore, Azure Files) via each cloud’s CSI driver, object storage client libraries (Amazon S3, Google Cloud Storage, Azure Blob Storage), storage access tiers and lifecycle policies, cloud-agnostic abstractions to avoid vendor lock-in — Spring’s
Resource/WritableResourceabstraction, Apache jclouds'BlobStore, and Spring Content — and integration testing against local emulators (S3Mock, fake-gcs-server, Azurite) now that MinIO and LocalStack are no longer free, no-account defaults.
APIs
GraphQL is covered in its own GraphQL Reference, including dedicated Spring for GraphQL integration pages.
Security
-
Spring Security — the filter-chain model, the method-security annotations (
@PreAuthorizeand friends), how theSecurityContextworks for the servlet and reactive stacks, and how it is built from a username/password credential or from a bearer JWT (OAuth2 Resource Server). -
Authorization Server & Social Login — building an OAuth2/OIDC authorization server with Spring Authorization Server (login/logout, token issuance), and "Sign in with Google / Microsoft / Apple" with
oauth2Login()— interfaces, database model, REST controller and REST clients. For the OAuth 2.0 / OpenID Connect protocol these two pages implement — grant types, tokens, the Security BCP, and passwordless and multi-factor authentication methods — see the OAuth Reference.
Server-side web UI frameworks
-
Server-Side Web UI Frameworks — Thymeleaf, Vaadin (linking out to the Vaadin Reference), and legacy JSF via JoinFaces, with a closing decision table.
Messaging
-
Messaging with Kafka — producing with
KafkaTemplate, consuming with@KafkaListener, serializers, and error handling with dead-letter topics.
Scheduling
-
Scheduling & ShedLock — in-process scheduling with
@Scheduled, the multi-instance duplicate-execution problem, and distributed locking with ShedLock.
Observability
-
Logging — Logback defaults, log levels, structured JSON logging, and routing logs to stdout vs. a file.
-
Metrics & Observability — Micrometer and Actuator, distributed tracing with OpenTelemetry, and Prometheus/Grafana.
Reactive programming
-
Reactive Programming —
Mono/Flux, operators, backpressure, testing withStepVerifier, how reactive transactions ride the ReactorContextrather than aThreadLocal, safely bridging to blocking code, and a link to a hands-on Reactor workshop.
Concurrency Alternatives
-
Concurrency Alternatives — Project Reactor, Java Virtual Threads, and Kotlin Coroutines side by side: execution model, pros/cons, code examples, how each handles transaction management, and setting up a mixed Java+Kotlin Maven/Gradle project.
Developer productivity tools
-
Lombok & MapStruct — Lombok’s boilerplate-reduction annotations and MapStruct’s generated DTO ↔ entity mappers, used together.
Testing
-
Unit & Integration Testing — JUnit 5 and Mockito, Spring Boot’s test slices, and
@SpringBootTestwith Testcontainers. -
Performance Testing with JMeter — test-plan structure, parameterization, and correlating results with Actuator/Prometheus metrics.
API-first development
-
API-First: REST & gRPC — contract-first REST with OpenAPI and contract-first gRPC with Protocol Buffers.
-
API-First: Messaging — contract-first Kafka messaging with Avro schemas and describing topics with AsyncAPI.
Build & quality
-
Maven Quality Plugins — JaCoCo coverage, Surefire vs. Failsafe, and static analysis with Checkstyle, SpotBugs, and PMD.
Architecture
-
Architectural Patterns — SOLID, hexagonal (ports & adapters) architecture, core DDD vocabulary, the transactional outbox pattern, listen-to-yourself, and sagas.
-
Distributed ID Generation — the coordination problem behind database-generated primary keys once multiple instances insert concurrently, Twitter’s Snowflake bit-packed ID layout and its ULID/TSID/UUIDv7 relatives, and wiring a Snowflake-style generator into Spring Boot as a custom Hibernate
IdentifierGeneratoror a plain bean.
Reference
-
Cheat Sheet — a one-page, downloadable PDF summary of the essentials above for quick memorization.
Bibliography
Official documentation (primary source for every page)
-
spring.io — the Spring project family home.
-
spring.io/projects/spring-boot and docs.spring.io/spring-boot/reference — Spring Boot 4.1.x reference documentation (getting started, core features, web, data, IO, messaging, testing, packaging, Actuator, how-to guides, build tool plugins).
-
docs.spring.io/spring-framework/reference — Spring Framework 7.0.x reference (IoC container, AOP, data access, web MVC/WebFlux).
-
Spring Data JPA, Spring Data MongoDB, Spring Data Couchbase, Spring Data Neo4j, and Spring Data Redis — the per-store Spring Data reference guides.
-
Caffeine wiki, Redis Pub/Sub, Redis keyspace notifications, and Redisson wiki — Local Cache — the local (Caffeine), Redis invalidation, and Redisson near-cache references used by the near-far caching page.
-
aws-efs-csi-driver, GKE Filestore CSI driver, and AKSazurefile-csi-driver— the Kubernetes CSI drivers mounting Amazon EFS, Google Cloud Filestore, and Azure Files, used by File Storage & Object Stores. -
Spring Cloud GCP reference documentation and Spring Cloud Azure Storage reference documentation — the Google Cloud Storage and Azure Blob Storage client starters (the Spring Cloud AWS reference below already covers its S3 integration).
-
Apache jclouds BlobStore guide — the provider-agnostic
BlobStoreAPI covering Amazon S3, Azure Blob Storage, Google Cloud Storage, and roughly thirty other backends through one common API. -
Spring Content — its GitHub repository is the primary documentation source for this Spring-Data-style
ContentStore/Storeabstraction over JPA/MongoDB entity content; a community-maintained project, not an official Spring/Pivotal one. -
Adobe S3Mock, fake-gcs-server, and Azurite — the actively-maintained, no-account local emulators for S3, Google Cloud Storage, and Azure Blob Storage respectively, each usable as a Testcontainers module, used by File Storage & Object Stores's integration-testing section.
-
Spring Framework — Data Access with JDBC and the
JdbcClient/JdbcTemplateAPI docs — low-level SQL access without JPA. -
Spring Framework — Transaction Management, declarative transaction management, and Spring Data JPA — Locking — transaction isolation levels, the
Isolationenum, and pessimistic locking with@Lock. -
Spring Framework — Programmatic Transaction Management and Reactive Transactions with Spring —
TransactionalOperator,ReactiveTransactionManager, and why reactive transaction state lives in the ReactorContext. -
Spring Cloud Commons —
@RefreshScope, Spring Cloud Config Client, Spring Cloud Config Server, Spring Cloud Bus endpoints, Spring Cloud Kubernetes — PropertySource reload, and Spring Cloud AWS reference — runtime configuration change providers. -
MongoTemplate API and template query operations —
MongoTemplatelow-level queries. -
Spring Data Couchbase — Template & direct operations —
CouchbaseTemplateand direct operations. -
Spring Data Neo4j — Custom queries and the
Neo4jClientAPI docs — low-level Cypher queries. -
Spring Framework — Thymeleaf integration and thymeleaf.org documentation — Thymeleaf and its Spring integration.
-
JoinFaces reference and joinfaces.org — JoinFaces (JSF on Spring Boot).
-
Spring Boot — Task Execution and Scheduling and Spring Framework — Task Execution and Scheduling — Spring scheduling.
-
ShedLock — its README is the only documentation source; no separate docs site exists.
-
Spring for Apache Kafka reference and Spring Boot — Apache Kafka Support.
-
Spring gRPC reference — the official Spring gRPC project reference.
-
Spring Boot — Actuator (including the "Observability", "Metrics", and "Tracing" pages) and Micrometer reference — Actuator and Micrometer.
-
Project Reactor 3 reference guide, in particular Threading and Schedulers — the
Schedulerfactories,boundedElasticsizing, and whereblock()throws. -
JEP 444: Virtual Threads — the JDK Enhancement Proposal defining virtual threads' execution model, mounting/unmounting, and carrier-thread pinning.
-
the Kotlin Coroutines guide and the Spring Framework reference — Coroutines —
suspendfunctions, structured concurrency, andTransactionalOperator.executeAndAwaitfor reactive transaction management under coroutines. -
Kotlin docs — Configure a Maven project — the
kotlin-maven-pluginordering, compiler plugins, and dependencies for mixed Java+Kotlin Maven builds. -
OpenAPI Generator (
openapi-generator-maven-plugin). -
Checkstyle, SpotBugs, and PMD — static analysis.
-
Transactional Outbox, Saga, and Domain Event — Chris Richardson’s microservices.io pattern catalog.
-
Listen to Yourself — Oded Shopen’s original write-up of the pattern (no more official source exists for this specific pattern name).
-
the Reactor workshop — the user’s own hands-on Reactor workshop, linked from Reactive Programming for exercises.
-
Spring Batch reference and Spring Boot — Batch Applications — jobs, steps, chunk vs. tasklet processing, the
JobRepository, and Spring Boot auto-configuration. -
Hibernate ORM documentation (User Guide + Javadoc) and the Jakarta Persistence specification — Hibernate as the default JPA provider behind
spring-boot-starter-data-jpa; see also Spring Boot — JPA and Spring Data. -
Hibernate Search documentation — keeping full-text indexes (Lucene, Elasticsearch, OpenSearch back ends) in sync with Hibernate ORM entities.
-
Spring Data Elasticsearch reference, the Elasticsearch Java API Client, and the Elasticsearch documentation —
@Documentmapping,ElasticsearchRepository/ElasticsearchOperations, and the query DSL. -
Apache Solr Reference Guide and the SolrJ API documentation (
Http2SolrClient,SolrQuery,SolrInputDocument) — Solr’s own integration path now that Spring Data for Apache Solr is discontinued (moved to the Spring Attic; not compatible with Spring Boot 3+/4). -
MongoDB Atlas Search documentation and Spring Data MongoDB — Aggregation Framework Support — search index definitions, analyzers,
$search/$searchMeta, and the general custom-AggregationOperationextensibility mechanism used to reach the native driver’s typed$searchbuilders. -
Spring Security reference (architecture, authentication, method security, reactive, OAuth2 login / client / resource server, testing) and the 6.x → 7.0 migration guide — the primary source for Spring Security.
-
Spring Authorization Server reference (core model, configuration model, protocol endpoints, JDBC persistence) — the primary source for Authorization Server & Social Login; Spring Authorization Server is now part of Spring Security 7 (announcement).
-
Twitter Engineering — "Announcing Snowflake" (archived; the original blog post and the
twitter-archive/snowflakeproject itself are no longer maintained), Instagram Engineering — "Sharding & IDs at Instagram", the ULID specification, and IETF RFC 9562 — Universally Unique IDentifiers (UUIDs) (defines UUIDv7) — the primary sources for Distributed ID Generation.
Local books (bibliography only — consulted while preparing these pages, not the primary source for any page; most predate Spring Boot 3/4, so on any discrepancy the official documentation above wins)
-
Rajput, Dinesh. Mastering Spring Boot 2.0. Packt Publishing, 2018. ISBN 978-1-78712-756-2 (paperback) / 978-1-78712-514-8 (eBook). Consulted as part of the bibliography for this section — see the publisher’s book page, packtpub.com, and the code bundle at PacktPublishing/Mastering-Spring-Boot-2.0.
-
Turnquist, Greg L. Learning Spring Boot 2.0, 2nd ed. Packt Publishing, 2018. ISBN 978-1-78646-378-4 (paperback) / 978-1-78646-820-8 (eBook). Consulted as part of the bibliography for this section — see the publisher’s book page and packtpub.com.
-
Mińkowski, Piotr. Mastering Spring Cloud. Packt Publishing, 2018. ISBN 978-1-78847-543-3 (paperback) / 978-1-78847-724-6 (eBook). Cited only for its distributed-systems vocabulary used as motivating context for sagas in Architectural Patterns — not as a source for a dedicated Spring Cloud page (out of scope for this section). See the publisher’s book page, packtpub.com, and the code bundle at PacktPublishing/Mastering-Spring-Cloud.
-
Davis, Adam L. Reactive Streams in Java: Concurrency with RxJava, Reactor, and Akka Streams. Apress, 2018. Consulted as part of the bibliography for this section — see the publisher’s book page, apress.com, and the code bundle at Apress/reactive-streams-in-java.
-
Rajput, Dinesh. Spring 5 Design Patterns. Packt Publishing, 2017. ISBN 978-1-78829-945-9 (paperback) / 978-1-78829-959-6 (eBook). Consulted as part of the bibliography for this section — see the publisher’s book page, packtpub.com, and the code bundle at PacktPublishing/Spring5-Design-Patterns.
-
Walls, Craig. Spring Boot in Action. Manning Publications, 2016. ISBN 9781617292545. Consulted as part of the bibliography for this section — see the publisher’s book page and manning.com.
-
Gutierrez, Felipe. Spring Boot Messaging: Messaging APIs for Enterprise and Integration Solutions. Apress (2017). Consulted as part of the bibliography for this section — see the publisher’s book page, apress.com, and the code bundle at Apress/spring-boot-messaging.
-
Walls, Craig. Spring in Action, 4th ed. (covers Spring 4). Manning Publications, 2015. ISBN 9781617291203. Consulted as part of the bibliography for this section — see the publisher’s book page and manning.com.
-
Minella, Michael T. The Definitive Guide to Spring Batch: Modern Finite Batch Processing in the Cloud, 2nd ed. Apress, 2019. ISBN 978-1-4842-3723-6 (paperback) / 978-1-4842-3724-3 (eBook). Consulted while preparing this section’s Spring Batch page — predates Spring Batch 5 (
JobBuilderreplacedJobBuilderFactory,javax.moved tojakarta.), so the official reference above wins on any discrepancy. See the publisher’s book page and apress.com. -
Bauer, Christian, Gavin King, and Gary Gregory. Java Persistence with Hibernate, 2nd ed. Manning Publications, 2016. ISBN 9781617290459. Consulted while preparing this section’s Hibernate page and Spring Data JPA (SQL) — covers JPA 2.1 /
javax.persistence, so it predates Jakarta Persistence 3.2 and Hibernate ORM 6/7. See the publisher’s book page and manning.com. -
Peak, Patrick, and Nick Heudecker. Hibernate Quickly. Manning Publications, 2006. ISBN 978-1-932394-41-2. Consulted as part of the bibliography for this section’s Hibernate page — covers Hibernate 3 with XML (
hbm.xml) mapping; retained only for its conceptual treatment of the ORM paradigm mismatch and the DAO pattern. See the publisher’s book page and manning.com. -
Bernard, Emmanuel, and John Griffin. Hibernate Search in Action. Manning Publications, 2009. ISBN 978-1-933988-64-1. Consulted for the full-text-search background behind this section’s Hibernate and Elasticsearch pages — predates modern Hibernate Search 6/7 (Elasticsearch back end,
jakarta.*). See the publisher’s book page and manning.com. -
Gheorghe, Radu, Matthew Lee Hinman, and Roy Russo. Elasticsearch in Action. Manning Publications, 2016. ISBN 9781617291623. Consulted while preparing this section’s Elasticsearch page — targets Elasticsearch 1.x/2.x (mapping types,
TransportClient), so the current Elasticsearch documentation and Java API Client above win on any discrepancy. See the publisher’s book page and manning.com. -
Grainger, Trey, and Timothy Potter. Solr in Action. Manning Publications, 2014. ISBN 9781617291029. Consulted while preparing this section’s Apache Solr page — targets Solr 4 / early SolrCloud, so the Apache Solr Reference Guide and SolrJ documentation above win on any discrepancy. See the publisher’s book page and manning.com.
-
Boyd, Ryan. Getting Started with OAuth 2.0. O’Reilly Media, 2012. ISBN 978-1-4493-1160-5. Consulted for the protocol-level OAuth 2.0 vocabulary behind Authorization Server & Social Login — predates OAuth 2.1, PKCE, and mature OIDC, so the Spring Security / Spring Authorization Server references above win on any discrepancy. See the publisher’s book page.