Foundation · Understand
Spring Boot Starters
A starter is one coordinate that pulls a curated, mutually compatible set of libraries; the Boot BOM decides their versions so you rarely have to.
Primary source: Spring Boot 3.5: Starters
Lesson 4 of 5
1d streakThe Architectural Question
Choosing library versions by hand pits your picks against the tested combinations in spring-boot-dependencies, and mismatches usually surface as NoSuchMethodError deep inside framework code rather than at compile time.
What this guide proves
- spring-boot-starter-web
- Transitive Dependencies
- Bill of Materials (BOM)
A starter chooses capabilities; the BOM chooses versions
A starter and a bill of materials solve different problems. A starter is a dependency descriptor for a capability such as servlet web, JPA, or security. Its transitive graph brings the APIs and runtime implementations normally needed for that capability. The spring-boot-dependencies BOM supplies reviewed versions for a much larger set of libraries. Importing the BOM does not add those libraries; it only manages versions when they are selected.
| Mechanism | Changes the classpath? | Owns versions? | Example |
|---|---|---|---|
| Starter | Yes, through transitive dependencies | Usually delegates to Boot dependency management | spring-boot-starter-web |
| BOM / dependencyManagement | No | Yes, for covered coordinates | spring-boot-dependencies |
| Direct dependency | Yes | Only when its version is declared or managed | org.postgresql:postgresql |
| Build plugin | Runs build behavior | No | spring-boot-maven-plugin |
Active Recall Checkpoint
If the Boot BOM manages PostgreSQL, why does the driver not appear until you declare it?
Hint: Version selection and dependency selection are separate operations.
Show answer & explanation
dependencyManagement supplies a version only if the dependency enters the graph. It does not add the driver. Declare the driver or a starter that transitively includes it, then the managed version applies.
Read the dependency graph as runtime evidence
./mvnw dependency:tree
./mvnw dependency:tree -Dincludes=org.springframework.boot,org.springframework,com.fasterxml.jackson.core,org.apache.tomcat.embed
./mvnw help:effective-pomcom.example:catalog:jar:0.0.1-SNAPSHOT \- org.springframework.boot:spring-boot-starter-web +- org.springframework:spring-webmvc +- org.springframework.boot:spring-boot-starter-json \- org.springframework.boot:spring-boot-starter-tomcat
The tree answers how an artifact arrived. The effective POM answers which dependency-management and plugin configuration Maven calculated after parent inheritance and BOM imports. Use both before editing versions: the declared POM is only one input to the effective build model.
Reproduce a version-alignment failure safely
- 01Record the managed Jackson version from the effective POM and run the test suite.
- 02Add an explicit incompatible Jackson version in a temporary branch.
- 03Inspect dependency:tree to prove which version won and which transitive request was omitted.
- 04Run a serialization test and capture the linkage error or behavioral mismatch.
- 05Remove the override and upgrade through a compatible Boot release when a newer library is required.
Why linkage errors appear late
Use it when
Use the smallest starter matching the capability and let Boot manage every covered version.
Reconsider when
Override a managed version only for a documented compatibility or security reason, with dependency-tree evidence and tests that execute the affected integration.
Runtime Architecture & Flow
Decision canvas
Evaluate the choice across three constraints
These are comparison criteria, not sequential steps. A strong answer states which constraint dominates in the current system.
spring-boot-starter-web
Ask how each option changes this guarantee, its operational cost, and its failure mode.
Transitive Dependencies
Ask how each option changes this guarantee, its operational cost, and its failure mode.
Bill of Materials (BOM)
Ask how each option changes this guarantee, its operational cost, and its failure mode.
Decision prompt: Use `mvn dependency:tree` or `./gradlew dependencies` to trace how `starter-web` pulls in Tomcat and Jackson.
Working Implementation
Code Walkthrough
Use `mvn dependency:tree` or `./gradlew dependencies` to trace how `starter-web` pulls in Tomcat and Jackson.
package com.example.starters;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.web.embedded.tomcat.TomcatServletWebServerFactory;
import org.springframework.boot.web.servlet.server.ServletWebServerFactory;
import org.springframework.context.annotation.Bean;
/**
* Demonstrates starter dependency aggregation and selective container customization.
* Starter dependencies (e.g. spring-boot-starter-web) bring transitive dependencies:
* - spring-web, spring-webmvc, tomcat-embed-core, jackson-databind.
*/
@SpringBootApplication
public class StartersDependencyLab {
@Bean
public ServletWebServerFactory servletWebServerFactory() {
TomcatServletWebServerFactory factory = new TomcatServletWebServerFactory();
factory.setPort(8081); // Programmatic starter customization
return factory;
}
}Synthesis & Production Verification
Production Acceptance Criteria
- Explain what a starter aggregates and what the BOM manages
- Trace transitive dependencies with mvn dependency:tree
- Predict which dependency wins when two versions collide
Key Takeaway
A starter selects a capability graph; the Boot BOM manages compatible versions without adding dependencies by itself.
Architectural & Technical Review
Core Interview Questions
Q01How is a Spring Boot starter different from the Boot BOM?Show answer
A starter adds a transitive dependency graph for a capability. The BOM contributes dependency-management versions for covered coordinates but does not add those libraries to the classpath.
Q02How do you determine why a library is on the runtime classpath?Show answer
Inspect the Maven or Gradle dependency graph to follow the path from the application to the transitive artifact, then inspect the effective build model to see which managed version won.
Q03Why can an explicit dependency override cause NoSuchMethodError?Show answer
Compilation and runtime linkage can observe incompatible binary versions after dependency mediation. The code compiles, but the loaded class lacks the method expected by another library.
Production Pitfalls
Critical Anti-Patterns
- Pitfall: Adding starters speculatively — Every starter adds real libraries and may activate matching auto-configuration, increasing startup, security, and upgrade surface.
- Pitfall: Treating a version override as a local change — One override can break every library compiled against the managed version. Require dependency-tree evidence and an integration test.
Primary Documentation & Specifications
Lesson Primary References
Supplementary Module Resources