- Chapter
- Chapter 1 — Spring Framework Fundamentals
- Prerequisites
- Topics 1.1–1.3
- You will be able to
- Map a business or technical need to the right Spring project, explain version alignment, and assess ecosystem lock-in
- Covers
- Spring Framework · Spring Boot · Spring Data · Spring Security · Spring Cloud · Spring Integration · Spring Batch · Spring Kafka
On this page
- 1. Concept / Definition
- 2. Why It Exists
- 3. Core Concepts
- 4. How It Works Internally
- 4A. Deep Dive — Support Lifecycles and Ecosystem Governance
- 5. APIs / Features / Syntax
- 6. Practical Examples
- 7. Common Problems & Mistakes
- 8. Performance & Production Considerations
- 9. Architecture & Design Considerations
- 10. Interview Questions & Answers
1Concept / Definition
The Spring ecosystem is the portfolio of open-source projects maintained under the Spring umbrella (spring.io) that build on the Spring Framework. The Framework supplies the container, AOP, web and data-access foundations; Spring Boot turns them into production-ready applications with minimal configuration; and a set of specialised projects — Data, Security, Cloud, Integration, Batch, Kafka and many more — solve specific enterprise problems using the same programming model.

2Why It Exists
- Enterprise systems need more than DI. Real systems need persistence, security, messaging, batch processing, distributed configuration and observability. Rather than each team integrating these ad hoc, Spring projects provide tested, idiomatic integrations.
- Consistency across problem domains. A Kafka listener, a JPA repository and an OAuth2 resource server are all configured, overridden and tested in the same way.
- Pace of change. Separate projects can follow their own technologies (a new Kafka client, a new OAuth spec) without waiting for a Framework release.
- Curated compatibility. Spring Boot's dependency management and the Spring Cloud release train certify combinations of versions, removing the "dependency hell" of assembling a stack by hand.
3Core Concepts
3.1 Spring Framework
The foundation: IoC container, AOP, MVC and WebFlux, transactions, JDBC/ORM integration, messaging abstractions, testing. Current generation: 7.0 (November 2025) with a JDK 17 minimum, Jakarta EE 11 alignment, JSpecify null-safety, API versioning, core resilience annotations and BeanRegistrar. Every other project depends on it.
3.2 Spring Boot
An opinionated layer for building stand-alone, production-grade applications.
- Auto-configuration — conditional configuration activated by classpath contents and properties (
@ConditionalOnClass,@ConditionalOnMissingBean). - Starters — curated dependency sets.
- Embedded servers — Tomcat (default) or Jetty inside an executable JAR.
- Externalised configuration —
application.yaml, profiles, environment variables, config trees. - Actuator — health, metrics (Micrometer), info, and management endpoints.
- Current generation: 4.0, built on Framework 7, with modularised auto-configuration, Jackson 3 by default, and HTTP service client auto-configuration. Covered in Volume III.
3.3 Spring Data
A family of modules providing a consistent repository abstraction over many stores.
- Common:
Repository,CrudRepository,ListCrudRepository,PagingAndSortingRepository, derived queries (findByStatusAndCreatedAfter), projections, auditing,@Query. - Store modules: JPA, JDBC, R2DBC, MongoDB, Redis, Cassandra, Elasticsearch, Neo4j, Couchbase, and more. Covered in Volume V.
3.4 Spring Security
Authentication and authorization for Servlet and reactive applications: SecurityFilterChain, password encoding, session management, CSRF protection, method security (@PreAuthorize), OAuth2 client and resource server, OIDC login, SAML 2.0, and passkeys. Spring Authorization Server provides OAuth 2.1/OIDC provider capabilities. Covered in Volume VI.
3.5 Spring Cloud
Patterns for distributed systems, delivered as a release train of sub-projects:
| Sub-project | Purpose |
|---|---|
| Spring Cloud Config | Centralised, versioned configuration (Git, Vault, JDBC backends) |
| Spring Cloud Gateway | API gateway on WebFlux or MVC: routing, filters, rate limiting |
| Spring Cloud Netflix (Eureka) / Consul / Kubernetes | Service discovery |
| Spring Cloud Circuit Breaker | Abstraction over Resilience4j |
| Spring Cloud OpenFeign | Declarative HTTP clients (maintenance mode; HTTP interface clients preferred) |
| Spring Cloud Stream | Binder-based event-driven microservices over Kafka, RabbitMQ and others |
| Spring Cloud Function | Business logic as functions deployable to serverless platforms |
Release trains are named by year (for example 2025.1, codename Oakwood) and each train is compatible with a specific Spring Boot line.
3.6 Spring Integration
An implementation of Enterprise Integration Patterns: message channels, filters, routers, splitters, aggregators, transformers, service activators, and inbound/outbound adapters for files, (S)FTP, HTTP, JDBC, JMS, AMQP, Kafka, MQTT, mail and more. Configured with a Java DSL (IntegrationFlow). Covered in Volume VII.
3.7 Spring Batch
A framework for robust, high-volume batch processing.
- Model:
Job→Step→ chunk-orientedItemReader→ItemProcessor→ItemWriter, or tasklet steps. - A
JobRepositoryrecords execution metadata to support restart, skip and retry policies. - Scaling: multi-threaded steps, partitioning, remote chunking.
3.8 Spring for Apache Kafka
Idiomatic Kafka support: KafkaTemplate for producing, @KafkaListener with listener containers for consuming, transactions (exactly-once within Kafka), error handlers with dead-letter publishing, non-blocking retry topics, and Kafka Streams integration. Spring Cloud Stream can use it as a binder when a broker-neutral model is preferred.
| Project | Primary problem | Key abstraction | Volume in this library |
|---|---|---|---|
| Spring Framework | Object wiring, AOP, web, tx | ApplicationContext | Book 4 Vol I–II, IV |
| Spring Boot | Setup, defaults, operations | Auto-configuration | Book 4 Vol III |
| Spring Data | Persistence boilerplate | Repository interfaces | Book 4 Vol V |
| Spring Security | Identity and access | SecurityFilterChain | Book 4 Vol VI |
| Spring Cloud | Distributed-system patterns | Config, gateway, discovery | Book 4 Vol VII, Book 7 |
| Spring Integration | Integration patterns | IntegrationFlow | Book 4 Vol VII |
| Spring Batch | Bulk processing | Job / Step / chunk | Book 4 Vol VII |
| Spring for Apache Kafka | Kafka producing/consuming | KafkaTemplate, @KafkaListener | Book 4 Vol VII, Book 6 |
4How It Works Internally
4.1 One integration pattern everywhere
Every ecosystem project integrates with the application in the same three steps, which is why they compose so easily:
1. Dependencies — a starter adds the project's JARs.
2. Auto-configuration — Boot registers infrastructure beans when conditions match (for example, KafkaAutoConfiguration creates a KafkaTemplate if spring-kafka is present and none is defined).
3. Extension by beans — you customise by declaring your own bean of the same type (auto-configuration backs off via @ConditionalOnMissingBean) or a *Customizer bean.
// Overriding an auto-configured bean: Boot backs off because one already exists
@Configuration
class KafkaConfig {
@Bean
DefaultErrorHandler kafkaErrorHandler(KafkaTemplate<Object, Object> template) {
var recoverer = new DeadLetterPublishingRecoverer(template);
return new DefaultErrorHandler(recoverer, new FixedBackOff(1_000L, 3));
}
}4.2 Version alignment
| Mechanism | Scope | Example |
|---|---|---|
| Framework BOM | All Framework modules | spring-framework-bom:7.0.x |
| Boot dependency management | Framework + Data + Security + Kafka + Batch + third-party libraries | spring-boot-dependencies:4.0.x |
| Spring Cloud BOM | All Spring Cloud sub-projects for one release train | spring-cloud-dependencies:2025.1.x |
The practical rule: pick a Spring Boot version, then pick the Spring Cloud release train documented as compatible with it, and let both manage everything else.
4ADeep Dive — Support Lifecycles and Ecosystem Governance
Support model. Spring projects follow a published support policy: each minor line receives open-source support for a limited period (around 13 months for Boot minors), and commercial support extends that for enterprises. Architects must plan upgrade cadence against these windows: a service left on an out-of-support line stops receiving CVE fixes in open source.
Generational alignment (current).
| Generation | Framework | Boot | Java baseline | Jakarta EE |
|---|---|---|---|---|
| Legacy | 5.3.x | 2.7.x | 8 (up to 17+) | Java EE 8 (javax.*) |
| Previous | 6.x | 3.x | 17 | 9–10 (jakarta.*) |
| Current | 7.0.x | 4.0.x | 17 minimum, 25 recommended | 11 |
Maintenance-mode projects. Some projects are superseded rather than evolved: Spring Cloud Netflix Hystrix and Ribbon were removed long ago in favour of Resilience4j and Spring Cloud LoadBalancer; Spring Cloud OpenFeign is in maintenance, with the Framework's HTTP interface clients (@HttpExchange) recommended for new code. Choosing a project should include checking its status on spring.io.
Newer projects worth knowing.
- Spring Modulith — structure and verify modular monoliths; application events between modules; generated documentation.
- Spring AI — portable abstractions for chat models, embeddings, vector stores, tool calling and retrieval-augmented generation.
- Spring gRPC, Spring Pulsar, Spring Shell, Spring Session, Spring REST Docs, Spring GraphQL, Spring Authorization Server.
5APIs / Features / Syntax
<!-- Spring Boot parent manages Framework, Data, Security, Kafka, Batch versions -->
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>4.0.0</version>
</parent>
<!-- Spring Cloud is aligned separately by its release-train BOM -->
<dependencyManagement>
<dependencies>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-dependencies</artifactId>
<version>2025.1.0</version>
<type>pom</type><scope>import</scope>
</dependency>
</dependencies>
</dependencyManagement>| Need | Starter / dependency |
|---|---|
| REST service | spring-boot-starter-webmvc |
| JPA persistence | spring-boot-starter-data-jpa |
| Resource server (JWT) | spring-boot-starter-oauth2-resource-server |
| Kafka | spring-kafka (auto-configured by Boot) |
| Batch jobs | spring-boot-starter-batch |
| Integration flows | spring-boot-starter-integration |
| Config client | spring-cloud-starter-config |
| Gateway | spring-cloud-starter-gateway-server-webflux (or -webmvc) |
| Observability | spring-boot-starter-actuator + Micrometer registry |

6Practical Examples
6.1 An order service combining five projects
@SpringBootApplication // Boot
public class OrderApp { public static void main(String[] a) { SpringApplication.run(OrderApp.class, a); } }
interface OrderRepository extends ListCrudRepository<Order, Long> { // Data
List<Order> findByStatus(Status status);
}
@Configuration
class SecurityConfig { // Security
@Bean
SecurityFilterChain api(HttpSecurity http) throws Exception {
return http.authorizeHttpRequests(a -> a.anyRequest().authenticated())
.oauth2ResourceServer(o -> o.jwt(Customizer.withDefaults()))
.build();
}
}
@Service
class OrderEvents {
private final KafkaTemplate<String, OrderPlaced> kafka; // Kafka
OrderEvents(KafkaTemplate<String, OrderPlaced> kafka) { this.kafka = kafka; }
void publish(OrderPlaced e) { kafka.send("orders.placed", e.orderId(), e); }
}
// application.yaml: spring.config.import: optional:configserver: <- Spring Cloud Config6.2 A restartable batch job
@Bean
Job settlementJob(JobRepository repo, Step settle) {
return new JobBuilder("settlement", repo).start(settle).build();
}
@Bean
Step settle(JobRepository repo, PlatformTransactionManager tx,
ItemReader<Payment> reader, ItemWriter<Settlement> writer) {
return new StepBuilder("settle", repo)
.<Payment, Settlement>chunk(500, tx) // commit every 500 items
.reader(reader).processor(Settlement::from).writer(writer)
.faultTolerant().skipLimit(10).skip(InvalidPaymentException.class)
.build();
}7Common Problems & Mistakes
- Incompatible Boot and Cloud versions. Using a Cloud release train not designed for the Boot line produces startup failures such as missing classes in auto-configuration. Always check the compatibility table.
- Choosing a project for résumé value. Adding Spring Cloud Gateway, Config Server and Eureka to a three-service system deployed on Kubernetes duplicates what the platform already provides (Ingress/Gateway API, ConfigMaps, DNS discovery).
- Confusing Spring Integration, Spring Cloud Stream and Spring Kafka. Kafka = Kafka-specific client support; Stream = broker-neutral event-driven microservices; Integration = general EIP toolkit with many protocols.
- Building on maintenance-mode projects. Starting new work on deprecated libraries creates immediate technical debt.
- Assuming Boot is required. All projects can be used with the plain Framework; Boot just removes the configuration effort.
8Performance & Production Considerations
| Project | Production consideration |
|---|---|
| Spring Boot | Actuator endpoints must be secured; expose only health/info publicly |
| Spring Data JPA | Watch N+1 queries and open-session-in-view (disable spring.jpa.open-in-view) |
| Spring Security | Filter-chain cost is small; JWT validation needs cached JWK sets |
| Spring Cloud Gateway | Reactive gateway is sensitive to blocking calls in filters |
| Spring Batch | JobRepository database contention at high step concurrency |
| Spring Kafka | Consumer concurrency ≤ partitions; tune max.poll.records against processing time |
| Spring Integration | Channel choice (direct vs queue vs executor) controls threading and back-pressure |
9Architecture & Design Considerations
9.1 Platform-first versus library-first
In Kubernetes environments, many Spring Cloud capabilities overlap with the platform. A useful decision matrix:
| Capability | Platform option | Spring option | Prefer Spring when… |
|---|---|---|---|
| Service discovery | Kubernetes DNS / Services | Eureka, Consul | Running outside Kubernetes or across clusters |
| Configuration | ConfigMaps, Secrets, external secret stores | Spring Cloud Config | You need Git-versioned config with refresh across many apps |
| Edge routing | Ingress / Gateway API / service mesh | Spring Cloud Gateway | Routing needs Java-level logic, custom filters or aggregation |
| Resilience | Service mesh retries/timeouts | Resilience4j, Framework 7 @Retryable | Behaviour depends on business semantics |
9.2 Managing lock-in
The ecosystem's consistency is also its lock-in. Mitigate by keeping domain logic framework-free, using standard protocols (HTTP, OAuth2, Kafka, SQL) at boundaries, and preferring Spring abstractions that wrap standards (JPA, JMS, Micrometer/OpenTelemetry) over proprietary ones.
10Interview Questions & Answers
What is the difference between Spring Framework and Spring Boot?
Spring Framework is the foundation and Spring Boot is an opinionated layer on top of it. The Framework provides the IoC container, AOP, Spring MVC and WebFlux, transaction management, data-access integration and the testing support, but it expects you to assemble and configure the pieces yourself. Boot adds starters that pull in compatible dependencies, auto-configuration that registers infrastructure beans when classes and properties are present, an embedded server in an executable JAR, externalised configuration and Actuator for health and metrics. Boot does not replace any Framework concept; a Boot application is still an ApplicationContext full of beans. In practice almost every new service uses Boot, but you debug it with Framework knowledge.
What does Spring Data provide?
Spring Data provides a consistent repository abstraction over many stores, so you declare an interface and Spring generates the implementation at startup. Extending ListCrudRepository or PagingAndSortingRepository gives you CRUD, paging and sorting; methods such as findByStatusAndCreatedAfter are parsed into queries from their names, and @Query covers the cases a name cannot express. It also supports projections, auditing fields such as @CreatedDate, and Example-based queries. The same model exists across store modules for JPA, JDBC, R2DBC, MongoDB, Redis, Cassandra, Elasticsearch and Neo4j, each adding store-specific features. The value is removing boilerplate data-access code, but you still need to understand the queries it generates, especially with JPA.
How do you choose compatible versions of Spring Boot and Spring Cloud?
Choose the Spring Boot version first, then take the Spring Cloud release train that the Spring Cloud project documents as compatible with that Boot line, and import its BOM in dependencyManagement. Boot's dependency management then aligns the Framework, Data, Security, Kafka, Batch and most third-party libraries, while spring-cloud-dependencies aligns the Cloud sub-projects. For example, Boot 4.0 pairs with the 2025.1 Oakwood train and Boot 3.5 with 2025.0. Never pin individual Spring artifact versions by hand. A mismatch usually fails at startup with ClassNotFoundException or NoSuchMethodError inside an auto-configuration class, and Spring Cloud's compatibility verifier reports an unsupported Boot version early, which you should not simply disable.
When would you use Spring Batch instead of a scheduled method?
Use Spring Batch when the work is large or must survive failure. Batch processes data in chunks, committing every N items, and records each job and step execution in a JobRepository, so a job that fails at item 400,000 restarts from the last committed chunk instead of from the beginning. It adds skip and retry policies, execution history for audit, and scaling through multi-threaded steps, partitioning and remote chunking. A @Scheduled method has none of that: if the JVM dies mid-run, you have no record of progress. It is fine for small, idempotent periodic tasks such as cache refreshes. In a cluster, both need a scheduler or lock so only one instance runs.
Spring Kafka, Spring Cloud Stream and Spring Integration can all consume Kafka messages. How do you choose?
Choose by how much of Kafka you need to see. Spring for Apache Kafka gives direct control: KafkaTemplate, @KafkaListener, partition assignment, transactions, DefaultErrorHandler with dead-letter publishing and non-blocking retry topics. I use it when Kafka is a deliberate architectural choice and its semantics matter. Spring Cloud Stream hides the broker behind binders and a functional model of Supplier, Function and Consumer beans, which suits many services sharing a convention or a possible broker change, at the cost of indirection when tuning. Spring Integration fits when Kafka is one channel in a wider flow involving files, SFTP, HTTP or JMS, with routing, splitting and transformation. Mixing all three in one service is usually a mistake.
How does an ecosystem project's auto-configuration let you override its defaults?
Ecosystem auto-configuration is written to back off. Most infrastructure beans are declared with @ConditionalOnMissingBean, so if you define your own bean of that type, Boot sees it during condition evaluation and skips its default; that is how a custom DefaultErrorHandler or ObjectMapper replaces the auto-configured one. Ordering matters: auto-configuration classes are processed after user configuration, which is why the check works. For smaller changes, prefer properties such as spring.kafka.consumer.max-poll-records, or Customizer beans such as RestClientCustomizer, which adjust the default instead of replacing it and keep the rest of Boot's wiring. When behaviour surprises you, the conditions report from --debug or the conditions Actuator endpoint shows exactly why each configuration matched.
On Kubernetes, would you deploy Eureka and Spring Cloud Config Server for a new microservice platform?
Usually not. Kubernetes already gives you service discovery through Services and DNS, configuration through ConfigMaps and Secrets, and rollouts through Deployments, so Eureka and a Config Server add two more stateful components to run, secure and upgrade without adding capability. I would use Spring Cloud Kubernetes or plain environment variables and mounted files, with an external secret store such as Vault or AWS Secrets Manager. I would add Config Server only for a real gap, such as Git-versioned configuration shared by many applications with audited, coordinated refresh, and Eureka or Consul only for discovery across clusters or with workloads outside Kubernetes. The rule is platform first, Spring library second.
How would you govern Spring ecosystem usage across a large enterprise?
I would treat the ecosystem as a platform product. A platform team publishes an internal BOM that imports spring-boot-dependencies and the matching Spring Cloud train, plus approved internal libraries, so services never choose Spring versions themselves. Alongside it sits an approved project list: standard, allowed with architecture review, and deprecated, such as OpenFeign for new work, each with its lifecycle status. Upgrade SLAs are tied to Spring's open-source support windows, for example staying within one Boot minor of current. Renovate raises upgrade pull requests, OpenRewrite automates migrations, and CI enforces dependency convergence and vulnerability scanning. Reference architectures, internal starters and a dashboard of BOM versions per service make the right path the easy one.
Test your knowledge on this topic →Flashcards from this topic's 8 questions, filtered by level and type.