Video in progress

Junior 🌱 Spring

Why do we need starters (spring-boot-starter-*)?

A starter is a "package" that, with a single dependency, brings in the libraries you need in versions that work with each other. Then Boot's auto-config sets them up.

📖 Answer

A REST API needs Spring MVC, Jackson, Tomcat and validation. Instead of adding them one by one and lining up their versions:

<dependency>
    <groupId>org.springframework.boot</groupId>
    <artifactId>spring-boot-starter-web</artifactId>
</dependency>

Notice there's no version — it comes from the Spring Boot BOM (the parent or dependencyManagement). That's why the libraries don't clash with each other.

The most commonly used ones:

  • starter-web — MVC + Tomcat;
  • starter-data-jpa — Hibernate + Spring Data;
  • starter-security;
  • starter-validation;
  • starter-actuator;
  • starter-test — JUnit 5, Mockito, AssertJ.

A starter itself contains almost no code. The real work happens in auto-configuration: when a required class shows up on the classpath, Boot creates the matching beans.