Pebellslearn by building
0%
RoadmapsMatrixCoursesSandboxSign in
Spring Boot Starters  ›  Lesson

The Starters You Will Use Most

Spring Boot Starters 12 minA handful of starters, such as web, validation, data-jpa, security, actuator and test, cover most services, so reading them reveals what an app does.

The Starters You Will Use Most

A new Spring Boot project on start.spring.io offers well over a hundred dependencies to tick. Most services use the same handful. Knowing those few by heart, and what each one switches on, lets you read any project's build file and guess its architecture in seconds.

The rule

Read a build file's starters and you know what the app does.

Here is library-service's pom.xml, trimmed to its starters:

<dependency><groupId>org.springframework.boot</groupId><artifactId>spring-boot-starter-web</artifactId></dependency>
<dependency><groupId>org.springframework.boot</groupId><artifactId>spring-boot-starter-validation</artifactId></dependency>
<dependency><groupId>org.springframework.boot</groupId><artifactId>spring-boot-starter-data-jpa</artifactId></dependency>
<dependency><groupId>org.springframework.boot</groupId><artifactId>spring-boot-starter-security</artifactId></dependency>
<dependency><groupId>org.springframework.boot</groupId><artifactId>spring-boot-starter-actuator</artifactId></dependency>
<dependency><groupId>org.postgresql</groupId><artifactId>postgresql</artifactId><scope>runtime</scope></dependency>
<dependency><groupId>org.springframework.boot</groupId><artifactId>spring-boot-starter-test</artifactId><scope>test</scope></dependency>
Starter What it switches on
web Spring MVC, Jackson, embedded Tomcat: blocking REST APIs
webflux Reactive web on Netty: non-blocking APIs
validation Bean Validation annotations such as @NotBlank and @Email
data-jpa Spring Data repositories plus Hibernate, talking to a SQL database
data-jdbc / jdbc Simpler SQL access without a full ORM
data-mongodb Repositories for MongoDB documents
security The security filter chain, locked down by default
oauth2-resource-server Accepting and checking bearer tokens
actuator Health, metrics and other production endpoints
test JUnit 5, Mockito, AssertJ and Spring's test support

Notice that a starter such as data-jpa does not include a database driver. You add the driver for your database (postgresql above), usually with runtime scope because your code never calls it directly.

The shortcut

Read starters in layers, from the outside of the app inward: how requests arrive (web or webflux) → how they are protected (security, oauth2) → where data lives (data-*, driver) → how it is operated (actuator) → how it is tested (test).

Reading library-service's build fileStep 1 of 4
  1. Requests

    web: a blocking REST API on Tomcat, with validation checking input.

A common mistake is adding both web and webflux without meaning to. When both are present, Boot runs a classic servlet (MVC) app, so the reactive stack is dead weight. Pick the one that matches how you write controllers.

Drills

Answer fast — trust the rule.

quick drill

Which starter brings JUnit 5, Mockito and AssertJ?

quick drill

A build file has data-jpa but no database driver. What is missing for PostgreSQL?

quick drill

Which starter should you add to check that a new book's title is not blank?

quick drill

A project's starters are webflux, data-mongodb and actuator. What kind of app is it most likely?

Remember

  • Read a build file's starters and you know what the app does.
  • Read in layers: requests, protection, data, operations, tests.
  • Trap: data starters need a driver, and web plus webflux together gives you plain MVC.

Practice — level up

0/1 solved

Write your answer, then compare it with a rubric and a model answer.

ExplainPick the starters

You are starting a new service that exposes a blocking REST API, stores data in MySQL through JPA, requires logins, reports health to the platform, and has unit tests. List the dependencies you would add and what each one is for.