liveBook · Manning

Dependency management

As explained in Spring in Action, Sixth Edition

Dependency management is the practice of declaring, resolving, and controlling the external libraries required by an application.

Dependency management declares and controls the external libraries an application needs. In a Maven-based Spring Boot project, the generated pom.xml records these dependencies and connects them to a managed Spring Boot version. section 1.2.2

A Spring Boot Maven project uses dependency management to:

  • Inherit library versions from the spring-boot-starter-parent instead of repeating each version. section 1.2.2
  • Declare Spring Web, Thymeleaf, DevTools, and testing dependencies under the dependencies element. section 1.2.2
  • Use starter artifacts that transitively pull in the libraries needed for a common Spring capability. section 1.2.2

Generated Maven configuration

Spring Initializr can generate a pom.xml whose parent identifies Spring Boot, whose properties select Java 11, and whose dependencies include starters for web development, templates, and testing. Maven then packages and runs the application using the project configuration. section 1.2.2

Listing 1.1 The initial Maven build specification
<?xml version="1.0" encoding="UTF-8"?><project
xmlns="http://maven.apache.org/POM/4.0.0"
  xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  xsi:schemaLocation="http://maven.apache.org/POM/4.0.0
        https://maven.apache.org/xsd/maven-4.0.0.xsd">
  <modelVersion>4.0.0</modelVersion>
  <parent>
    <groupId>org.springframework.boot</groupId>
    <artifactId>spring-boot-starter-parent</artifactId>
    <version>2.5.3</version>                              #1
    <relativePath />
  </parent>
  <groupId>sia</groupId>
  <artifactId>taco-cloud</artifactId>
  <version>0.0.1-SNAPSHOT</version>
  <name>taco-cloud</name>
  <description>Taco Cloud Example</description>
 
  <properties>
    <java.version>11</java.version>
  </properties>
 
  <dependencies>
    <dependency>                                        #2
      <groupId>org.springframework.boot</groupId>
      <artifactId>spring-boot-starter-thymeleaf</artifactId>
    </dependency>
 
    <dependency>
      <groupId>org.springframework.boot</groupId>
      <artifactId>spring-boot-starter-web</artifactId>
    </dependency>
 
    <dependency>
      <groupId>org.springframework.boot</groupId>
      <artifactId>spring-boot-devtools</artifactId>
      <scope>runtime</scope>
      <optional>true</optional>
    </dependency>
 
    <dependency>
      <groupId>org.springframework.boot</groupId>
      <artifactId>spring-boot-starter-test</artifactId>
      <scope>test</scope>
      <exclusions>
        <exclusion>
          <groupId>org.junit.vintage</groupId>
          <artifactId>junit-vintage-engine</artifactId>
        </exclusion>
      </exclusions>
    </dependency>
 
  </dependencies>
 
  <build>
    <plugins>
      <plugin>                                          #3
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-maven-plugin</artifactId>
      </plugin>
    </plugins>
  </build>
 
  <repositories>
    <repository>
      <id>spring-milestones</id>
      <name>Spring Milestones</name>
      <url>https://repo.spring.io/milestone</url>
    </repository>
  </repositories>
  <pluginRepositories>
    <pluginRepository>
      <id>spring-milestones</id>
      <name>Spring Milestones</name>
      <url>https://repo.spring.io/milestone</url>
    </pluginRepository>
  </pluginRepositories>
 
</project>

Inspect the complete initial Maven build specification, including the parent POM, Java version, and dependency declarations. section 1.2.2

How Spring in Action, Sixth Edition covers it

How deep it goes
Explains parent-managed versions, declared dependencies, and starter transitivity without detailing conflict-resolution procedures.
Examples
Uses a generated pom.xml containing Web, Thymeleaf, DevTools, and testing dependencies.
What it assumes
Assumes a Spring Initializr project configured for Maven and defines parent POMs and starter dependencies in context.
What you can do after
Operate Maven dependency configuration by declaring starters and inheriting versions from Spring Boot’s parent POM.
How it connects
Connects Maven POMs with Spring Initializr, Spring Boot parent POMs, starter dependencies, and testing.

Also explained in

Compare how 5 books explain dependency management →

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Spring in Action, Sixth Edition. The section links point to the parts of the book it draws on.