Module 4. Starters and BOM: How to Avoid Dependency Chaos

Module goal

Learn to build Spring Boot projects without dependency conflicts and version drift.

What we cover

  • What a starter is and why it exists.
  • How BOM-based dependency management works.
  • How to inspect and control dependency trees.

Step 1. What is a starter

A starter is a curated dependency bundle for a specific scenario.

Examples:

  • spring-boot-starter-web
  • spring-boot-starter-data-jpa
  • spring-boot-starter-security
  • spring-boot-starter-test

Step 2. Why starter-based setup is better

  • Less manual work.
  • Compatible versions out of the box.
  • Lower runtime conflict risk.

Step 3. Practice: baseline Gradle setup

dependencies {
    implementation 'org.springframework.boot:spring-boot-starter-web'
    implementation 'org.springframework.boot:spring-boot-starter-validation'
    implementation 'org.springframework.boot:spring-boot-starter-data-jpa'
    runtimeOnly 'org.postgresql:postgresql'
    testImplementation 'org.springframework.boot:spring-boot-starter-test'
}

Step 4. What Spring Boot BOM does

BOM defines compatible versions for transitive dependencies. In most cases, you should not hardcode versions for Boot-managed artifacts.

Step 5. Dependency tree inspection

Run periodically:

./gradlew dependencies

and inspect actual resolved versions.

Common mistakes

  • Adding many starters "just in case".
  • Explicitly pinning versions already managed by BOM.
  • Keeping unused dependencies.

Mini homework

  1. Build a minimal REST + JPA + PostgreSQL app.
  2. Inspect dependency tree and list 5 key libraries.
  3. Remove one unnecessary dependency and confirm behavior still works.

Checklist

  • I understand starter vs regular library.
  • I understand why BOM exists.
  • I can read and reason about dependency trees.
Glossary
bean
An object managed by the Spring container.
IoC
Inversion of Control, a design principle where a framework manages object creation and wiring.
dependency injection
A technique where required dependencies are provided to an object from the outside.
application context
The Spring container that stores beans, configuration, and runtime wiring.
auto-configuration
Spring Boot behavior that configures application components based on dependencies and settings.
starter
A Spring Boot dependency bundle that brings related libraries and default configuration together.
dependency management
The practice of controlling dependency versions and relationships in a project.
controller
A component that handles incoming requests and returns responses or view models.
service layer
The application layer where business logic and use-case orchestration usually live.
repository layer
The application layer responsible for data access and persistence operations.
REST controller
A controller that exposes HTTP endpoints and usually returns JSON or another response body.
endpoint
A specific API address and operation that clients can call.
request mapping
The configuration that connects an HTTP request path and method to controller code.
Spring Security
The Spring project used to implement authentication, authorization, and security filters.
authentication
The process of proving who a user or client is.
authorization
The process of deciding what an authenticated user or client is allowed to do.
filter chain
An ordered set of web filters that process a request before it reaches the application handler.
observability
The ability to understand system behavior from signals such as logs, metrics, traces, and health checks.