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

15 min

Lesson 4 of 5

1d streak

The 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.

MechanismChanges the classpath?Owns versions?Example
StarterYes, through transitive dependenciesUsually delegates to Boot dependency managementspring-boot-starter-web
BOM / dependencyManagementNoYes, for covered coordinatesspring-boot-dependencies
Direct dependencyYesOnly when its version is declared or managedorg.postgresql:postgresql
Build pluginRuns build behaviorNospring-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

terminal
./mvnw dependency:tree
./mvnw dependency:tree -Dincludes=org.springframework.boot,org.springframework,com.fasterxml.jackson.core,org.apache.tomcat.embed
./mvnw help:effective-pom
Terminal / Diagnostic Output
com.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

  1. 01Record the managed Jackson version from the effective POM and run the test suite.
  2. 02Add an explicit incompatible Jackson version in a temporary branch.
  3. 03Inspect dependency:tree to prove which version won and which transitive request was omitted.
  4. 04Run a serialization test and capture the linkage error or behavioral mismatch.
  5. 05Remove the override and upgrade through a compatible Boot release when a newer library is required.

Why linkage errors appear late

Compilation can succeed against a method present in one artifact while runtime loads a different binary selected by dependency mediation. NoSuchMethodError and NoClassDefFoundError are classpath evidence, not problems solved by catching exceptions in application code.

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.

CRITERION 01

spring-boot-starter-web

Ask how each option changes this guarantee, its operational cost, and its failure mode.

CRITERION 02

Transitive Dependencies

Ask how each option changes this guarantee, its operational cost, and its failure mode.

CRITERION 03

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.

StartersDependencyLab.java
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;
    }
}
Starters bundle tested, version-compatible dependencies governed by the Spring Boot Dependencies BOM.
Transitive dependencies can be inspected via mvn dependency:tree or gradle dependencies.
Default container starters (Tomcat) can be excluded and swapped with Jetty or Undertow without changing code.

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

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