Understanding spring-boot-starter-parent

The spring-boot-starter-parent dependency inherits from spring-boot-dependencies, which is defined at the top of the POM. The following code snippet shows an extract from spring-boot-starter-parent:

    <parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-dependencies</artifactId>
<relativePath>../../spring-boot-dependencies</relativePath>
</parent>

spring-boot-dependencies provides default dependency management for all the dependencies that Spring Boot uses. The following code shows the different versions of various dependencies that are configured in spring-boot-dependencies:

<activemq.version>5.15.8</activemq.version>
<aspectj.version>1.9.2</aspectj.version>
<ehcache.version>2.10.6</ehcache.version>
<elasticsearch.version>6.4.3</elasticsearch.version>
<gson.version>2.8.5</gson.version>
<h2.version>1.4.197</h2.version>
<hazelcast.version>3.11</hazelcast.version>
<hibernate.version>5.3.7.Final</hibernate.version>
<hibernate-validator.version>6.0.13.Final</hibernate-validator.version>
<hsqldb.version>2.4.1</hsqldb.version>
<htmlunit.version>2.33</htmlunit.version>
<jackson.version>2.9.7</jackson.version>
<jersey.version>2.27</jersey.version>
<jetty.version>9.4.12.v20180830</jetty.version>
<junit.version>4.12</junit.version>
<junit-jupiter.version>5.3.2</junit-jupiter.version>
<mockito.version>2.23.4</mockito.version>
<selenium.version>3.14.0</selenium.version>
<servlet-api.version>4.0.1</servlet-api.version>
<spring.version>5.1.3.RELEASE</spring.version>
<spring-amqp.version>2.1.2.RELEASE</spring-amqp.version>
<spring-batch.version>4.1.0.RELEASE</spring-batch.version>
<spring-hateoas.version>0.25.0.RELEASE</spring-hateoas.version>
<spring-restdocs.version>2.0.2.RELEASE</spring-restdocs.version>
<spring-security.version>5.1.2.RELEASE</spring-security.version>
<spring-ws.version>3.0.4.RELEASE</spring-ws.version>
<tomcat.version>9.0.13</tomcat.version>
<xml-apis.version>1.4.01</xml-apis.version>

If we want to override a specific version of a dependency, we can do that by providing a property with the correct name in the pom.xml file of our application. The following code snippet shows an example of configuring a specific version of Mockito:

    <properties>
<mockito.version>1.10.20</mockito.version>
</properties>

The following are some of the other things that are defined in spring-boot-starter-parent:

  • The default Java version, <java.version>1.8</java.version>.
  • The default configuration for Maven plugins:
    • maven-failsafe-plugin
    • maven-surefire-plugin
    • git-commit-id-plugin

Compatibility between different versions of frameworks is one of the major problems that's faced by developers.

How do I find the latest Spring Session version that is compatible with a specific version of Spring? The usual answer would be to read the documentation.

However, if we use Spring Boot, this is made simple by spring-boot-starter-parent. If we want to upgrade to a newer Spring version, all we need to do is find the spring-boot-starter-parent dependency for that Spring version.

Once we upgrade our application to use that specific version of spring-boot-starter-parent, we would have all the other dependencies upgraded to the versions that are compatible with the new Spring version. Hence, this is one less problem for developers to handle, which is something that always makes me happy.
..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset