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 @Configuration each 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-jpa plugins, a pros/cons comparison, a side-by-side REST endpoint, and guidance on which language to choose.

  • Configuration & Profiles — externalized configuration and precedence, @ConfigurationProperties vs. @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, @Version optimistic locking, entity inheritance across stores, keyset scrolling with Window<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, @Version optimistic locking, auditing, Window<T> keyset scrolling, plus custom queries with JdbcClient/JdbcTemplate.

  • Spring Data MongoDB — MongoRepository, document mapping, polymorphic documents (@TypeAlias), indexes, auditing, @Version optimistic locking, transactions, Window<T> keyset scrolling, plus custom queries with MongoTemplate.

  • 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 with CouchbaseTemplate.

  • Spring Data Neo4j — @Node/@Relationship mapping, node inheritance via multiple labels, Neo4jRepository, Cypher queries, transactions, @Version optimistic locking, plus custom queries with Neo4jClient.

  • Transaction Isolation & Locking — the @Transactional isolation attribute and its performance impact, pessimistic locking with @Lock and lock timeouts, and how it compares to @Version optimistic 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-jpa wires 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’s RLocalCachedMap).

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/WritableResource abstraction, 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

  • REST APIs — Spring MVC @RestController`s, exception handling with `ProblemDetail, and Spring WebFlux for reactive REST.

  • gRPC APIs — gRPC service definitions, the official Spring gRPC project’s @GrpcService/@ImportGrpcClients, interceptors, and error mapping.

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 (@PreAuthorize and friends), how the SecurityContext works 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 with StepVerifier, how reactive transactions ride the Reactor Context rather than a ThreadLocal, 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

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 IdentifierGenerator or 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)

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 (JobBuilder replaced JobBuilderFactory, javax. moved to jakarta.), 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.