Card 01/ 06
Spring Boot Starters: One Dependency Instead of a Dozen
A starter holds no code, only a list of libraries at versions Boot has tested together.
A starter is a dependency that contains no code of its own, only a list of other dependencies at versions Spring Boot has tested together. Adding one starter to a project brings in everything one piece of functionality needs, such as building a web API, with the versions already matched.
Adding Spring MVC to a project by hand means choosing Spring Web, a JSON library and a server library, and making sure their versions work together: three separate decisions on every project, each one a chance to get a version wrong. In Maven's pom.xml (the file that lists a Java project's dependencies) it looks like this:
<!-- spring-boot-starter-web instead of this -->
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-web</artifactId>
<version>6.1.13</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-webmvc</artifactId>
<version>6.1.13</version>
</dependency>
<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-databind</artifactId>
<version>2.17.2</version>
</dependency>
<dependency>
<groupId>org.apache.tomcat.embed</groupId>
<artifactId>tomcat-embed-core</artifactId>
<version>10.1.30</version>
</dependency>spring-boot-starter-web replaces all of it with one entry and no version numbers. The versions come from Spring Boot's own version list, called a BOM (bill of materials): one published list that fixes the version of every library Boot supports, so the ones in your project always agree.
A starter changes how many decisions you make, not what your application can do. Every library it brings in is an ordinary dependency you could have added yourself.
So upgrading Spring Boot upgrades the whole set at once, to versions tested together, and a project never has to work out on its own which version of Jackson, the JSON library, goes with which Spring.
← → move through sections and cards