Spring Boot provides a number of “Starter POMs” that make easy to add jars to your
classpath. Our sample application has already used
spring-boot-starter-parent
in the
parent
section of the POM. The
spring-boot-starter-parent
is a special starter
that provides useful Maven defaults. It also provides a
dependency-management
section
so that you can omit
version
tags for “blessed” dependencies.
Other “Starter POMs” simply provide dependencies that you are likely to need when
developing a specific type of application. Since we are developing a web application, we
will add a
spring-boot-starter-web
dependency — but before that, let’s look at what we
currently have.
$ mvn dependency:tree
[INFO] com.example:myproject:jar:0.0.1-SNAPSHOT
The
mvn dependency:tree
command prints tree representation of your project dependencies.
You can see that
spring-boot-starter-parent
provides no
dependencies by itself. Let’s edit our
pom.xml
and add the
spring-boot-starter-web
dependency
just below the
parent
section:
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
</dependencies>
If you run
mvn dependency:tree
again, you will see that there are now a number of
additional dependencies, including the Tomcat web server and Spring Boot itself.