Overview of Spring Boot Starter Parent - RameshMF/spring-boot-developers-guide GitHub Wiki
In this article, we will discuss how Spring Boot Starter Parent helps with managing dependency versions, the Java version used by the project and the default configuration for plug-ins.
In this article, we will discuss spring-boot-starter-parent dependency with respect to maven.
- What is the Spring Boot Starter Parent and How to use it?
- Parent Project Features
- What is inside Spring Boot Starter Parent?
- Using Spring Boot without the Parent POM
- What does Spring Boot Starter Parent inherit from spring-boot-dependencies?
All Spring Boot projects typically use spring-boot-starter-parent as the parent in pom.xml.
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>1.4.0.RELEASE</version>
</parent>
Parent Poms allow you to manage the following things for multiple child projects and modules:
- Configuration - Java Version and Other Properties
- Dependency Management - Version of dependencies
- Default Plugin Configuration
We should need to specify only the Spring Boot version number on this dependency. If you import additional starters, you can safely omit the version number.
For example:
diagram
Maven users can inherit from the spring-boot-starter-parent project to obtain sensible defaults. The parent project provides the following features:
- Java 1.8 as the default compiler level.
- UTF-8 source encoding.
- A Dependency Management section, inherited from the spring-boot-dependencies pom, that manages the versions of common dependencies. This dependency management lets you omit tags for those dependencies when used in your own pom.
- An execution of the repackage goal with a repackage execution id.
- Sensible resource filtering.
- Sensible plugin configuration (exec plugin, Git commit ID, and shade).
- Sensible resource filtering for application.properties and application.yml including profile-specific files (for example, application-dev.properties and application-dev.yml) Note that, since the application.properties and application.yml files accept Spring style placeholders (${…}), the Maven filtering is changed to use @..@ placeholders. (You can override that by setting a Maven property called resource.delimiter.)
Spring Boot Starter Parent has spring-boot-dependencies as the parent pom. It inherits dependency management from spring-boot-dependencies.
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-dependencies</artifactId>
<version>2.0.4.RELEASE</version>
<relativePath>../../spring-boot-dependencies</relativePath>
</parent>
For Spring Boot 2+ the default java version is 1.8. A few other settings related to encoding and source, target version are also set in the parent pom.
<properties>
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
<java.version>1.8</java.version>
<resource.delimiter>@</resource.delimiter>
<maven.compiler.source>${java.version}</maven.compiler.source>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<maven.compiler.target>${java.version}</maven.compiler.target>
</properties>
Spring Boot Starter Parent specifies the default configuration for a host of plugins including maven-failsafe-plugin, maven-jar-plugin, maven-surefire-plugin and maven-war-plugin etc.
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<parameters>true</parameters>
</configuration>
</plugin>
<plugin>
<artifactId>maven-failsafe-plugin</artifactId>
<executions>
<execution>
<goals>
<goal>integration-test</goal>
<goal>verify</goal>
</goals>
</execution>
</executions>
<configuration>
<classesDirectory>${project.build.outputDirectory}</classesDirectory>
</configuration>
</plugin>
<plugin>
<artifactId>maven-jar-plugin</artifactId>
<configuration>
<archive>
<manifest>
<mainClass>${start-class}</mainClass>
<addDefaultImplementationEntries>true</addDefaultImplementationEntries>
</manifest>
</archive>
</configuration>
</plugin>
<plugin>
<artifactId>maven-war-plugin</artifactId>
<configuration>
<archive>
<manifest>
<mainClass>${start-class}</mainClass>
<addDefaultImplementationEntries>true</addDefaultImplementationEntries>
</manifest>
</archive>
</configuration>
</plugin>
Not everyone likes inheriting from the spring-boot-starter-parent POM. You may have your own corporate standard parent that you need to use or you may prefer to explicitly declare all your Maven configuration.
If you do not want to use the spring-boot-starter-parent, you can still keep the benefit of the dependency management (but not the plugin management) by using a scope=import dependency, as follows:
<dependencyManagement>
<dependencies>
<dependency>
<!-- Import dependency management from Spring Boot -->
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-dependencies</artifactId>
<version>2.1.0.BUILD-SNAPSHOT</version>
<type>pom</type>
<scope>import</scope>
</dependency>
</dependencies>
</dependencyManagement>
The next step is we need to add an entry in the dependencyManagement of your project before the spring-boot-dependencies entry. For instance, to upgrade to another Spring Data release train, you could add the following element to your pom.xml:
<dependencyManagement>
<dependencies>
<!-- Override Spring Data release train provided by Spring Boot -->
<dependency>
<groupId>org.springframework.data</groupId>
<artifactId>spring-data-releasetrain</artifactId>
<version>Fowler-SR2</version>
<type>pom</type>
<scope>import</scope>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-dependencies</artifactId>
<version>2.1.0.BUILD-SNAPSHOT</version>
<type>pom</type>
<scope>import</scope>
</dependency>
</dependencies>
</dependencyManagement>
Spring Boot Dependencies defines the default dependency management for all Spring Boot projects. If we would want to use a new version of a specific dependency, we can override the version by specifying a new property in the project pom. The extract below shows some of the important dependencies that are managed by Spring Boot Dependencies parent pom. Since Spring Boot Starter Parent inherit from spring-boot-dependencies, it shares all these characteristics as well.
<properties>
<activemq.version>5.15.4</activemq.version>
<antlr2.version>2.7.7</antlr2.version>
<appengine-sdk.version>1.9.64</appengine-sdk.version>
<artemis.version>2.4.0</artemis.version>
<aspectj.version>1.8.13</aspectj.version>
<assertj.version>3.9.1</assertj.version>
<atomikos.version>4.0.6</atomikos.version>
<bitronix.version>2.1.4</bitronix.version>
<build-helper-maven-plugin.version>3.0.0</build-helper-maven-plugin.version>
<byte-buddy.version>1.7.11</byte-buddy.version>
<caffeine.version>2.6.2</caffeine.version>
<cassandra-driver.version>3.4.0</cassandra-driver.version>
<classmate.version>1.3.4</classmate.version>
<commons-codec.version>1.11</commons-codec.version>
<commons-dbcp2.version>2.2.0</commons-dbcp2.version>
<commons-lang3.version>3.7</commons-lang3.version>
<commons-pool.version>1.6</commons-pool.version>
<commons-pool2.version>2.5.0</commons-pool2.version>
<couchbase-cache-client.version>2.1.0</couchbase-cache-client.version>
<couchbase-client.version>2.5.9</couchbase-client.version>
<derby.version>10.14.1.0</derby.version>
<dom4j.version>1.6.1</dom4j.version>
<dropwizard-metrics.version>3.2.6</dropwizard-metrics.version>
<ehcache.version>2.10.5</ehcache.version>
<ehcache3.version>3.5.2</ehcache3.version>
<elasticsearch.version>5.6.10</elasticsearch.version>
<embedded-mongo.version>2.0.3</embedded-mongo.version>
<exec-maven-plugin.version>1.5.0</exec-maven-plugin.version>
<flatten-maven-plugin.version>1.0.1</flatten-maven-plugin.version>
<flyway.version>5.0.7</flyway.version>
<freemarker.version>2.3.28</freemarker.version>
<git-commit-id-plugin.version>2.2.4</git-commit-id-plugin.version>
<glassfish-el.version>3.0.0</glassfish-el.version>
<groovy.version>2.4.15</groovy.version>
<gson.version>2.8.5</gson.version>
<h2.version>1.4.197</h2.version>
<hamcrest.version>1.3</hamcrest.version>
<hazelcast.version>3.9.4</hazelcast.version>
<hazelcast-hibernate5.version>1.2.3</hazelcast-hibernate5.version>
<hibernate.version>5.2.17.Final</hibernate.version>
<hibernate-jpa-2.1-api.version>1.0.2.Final</hibernate-jpa-2.1-api.version>
<hibernate-validator.version>6.0.11.Final</hibernate-validator.version>
<hikaricp.version>2.7.9</hikaricp.version>
<hsqldb.version>2.4.1</hsqldb.version>
<htmlunit.version>2.29</htmlunit.version>
<httpasyncclient.version>4.1.3</httpasyncclient.version>
<httpclient.version>4.5.6</httpclient.version>
<httpcore.version>4.4.10</httpcore.version>
<infinispan.version>9.1.7.Final</infinispan.version>
<influxdb-java.version>2.9</influxdb-java.version>
<jackson.version>2.9.6</jackson.version>
<janino.version>3.0.8</janino.version>
<javax-annotation.version>1.3.2</javax-annotation.version>
<javax-cache.version>1.1.0</javax-cache.version>
<javax-jaxb.version>2.3.0</javax-jaxb.version>
<javax-jms.version>2.0.1</javax-jms.version>
<javax-json.version>1.1.2</javax-json.version>
<javax-jsonb.version>1.0</javax-jsonb.version>
<javax-mail.version>1.6.1</javax-mail.version>
<javax-money.version>1.0.3</javax-money.version>
<javax-transaction.version>1.2</javax-transaction.version>
<javax-validation.version>2.0.1.Final</javax-validation.version>
<jaxen.version>1.1.6</jaxen.version>
<jaybird.version>3.0.4</jaybird.version>
<jboss-logging.version>3.3.2.Final</jboss-logging.version>
<jboss-transaction-spi.version>7.6.0.Final</jboss-transaction-spi.version>
<jdom2.version>2.0.6</jdom2.version>
<jedis.version>2.9.0</jedis.version>
<jersey.version>2.26</jersey.version>
<jest.version>5.3.3</jest.version>
<jetty.version>9.4.11.v20180605</jetty.version>
<jetty-el.version>8.5.24.2</jetty-el.version>
<jetty-jsp.version>2.2.0.v201112011158</jetty-jsp.version>
<jmustache.version>1.14</jmustache.version>
<jna.version>4.5.2</jna.version>
<joda-time.version>2.9.9</joda-time.version>
<johnzon-jsonb.version>1.1.8</johnzon-jsonb.version>
<jolokia.version>1.5.0</jolokia.version>
<jooq.version>3.10.8</jooq.version>
<jsonassert.version>1.5.0</jsonassert.version>
<json-path.version>2.4.0</json-path.version>
<jstl.version>1.2</jstl.version>
<jtds.version>1.3.1</jtds.version>
<junit.version>4.12</junit.version>
<junit-jupiter.version>5.1.1</junit-jupiter.version>
<junit-platform.version>1.1.0</junit-platform.version>
<kafka.version>1.0.2</kafka.version>
<kotlin.version>1.2.51</kotlin.version>
<lettuce.version>5.0.4.RELEASE</lettuce.version>
<liquibase.version>3.5.5</liquibase.version>
<log4j2.version>2.10.0</log4j2.version>
<logback.version>1.2.3</logback.version>
<lombok.version>1.16.22</lombok.version>
<mariadb.version>2.2.6</mariadb.version>
<maven-antrun-plugin.version>1.8</maven-antrun-plugin.version>
<maven-assembly-plugin.version>3.1.0</maven-assembly-plugin.version>
<maven-clean-plugin.version>3.0.0</maven-clean-plugin.version>
<maven-compiler-plugin.version>3.7.0</maven-compiler-plugin.version>
<maven-dependency-plugin.version>3.0.2</maven-dependency-plugin.version>
<maven-deploy-plugin.version>2.8.2</maven-deploy-plugin.version>
<maven-eclipse-plugin.version>2.10</maven-eclipse-plugin.version>
<maven-enforcer-plugin.version>3.0.0-M2</maven-enforcer-plugin.version>
<maven-failsafe-plugin.version>2.21.0</maven-failsafe-plugin.version>
<maven-help-plugin.version>2.2</maven-help-plugin.version>
<maven-install-plugin.version>2.5.2</maven-install-plugin.version>
<maven-invoker-plugin.version>3.1.0</maven-invoker-plugin.version>
<maven-jar-plugin.version>3.0.2</maven-jar-plugin.version>
<maven-javadoc-plugin.version>3.0.1</maven-javadoc-plugin.version>
<maven-resources-plugin.version>3.0.2</maven-resources-plugin.version>
<maven-shade-plugin.version>2.4.3</maven-shade-plugin.version>
<maven-site-plugin.version>3.6</maven-site-plugin.version>
<maven-source-plugin.version>3.0.1</maven-source-plugin.version>
<maven-surefire-plugin.version>2.21.0</maven-surefire-plugin.version>
<maven-war-plugin.version>3.1.0</maven-war-plugin.version>
<micrometer.version>1.0.6</micrometer.version>
<mockito.version>2.15.0</mockito.version>
<mongodb.version>3.6.4</mongodb.version>
<mongo-driver-reactivestreams.version>1.7.1</mongo-driver-reactivestreams.version>
<mssql-jdbc.version>6.2.2.jre8</mssql-jdbc.version>
<mysql.version>5.1.46</mysql.version>
<narayana.version>5.8.2.Final</narayana.version>
<nekohtml.version>1.9.22</nekohtml.version>
<neo4j-ogm.version>3.1.0</neo4j-ogm.version>
<netty.version>4.1.27.Final</netty.version>
<nio-multipart-parser.version>1.1.0</nio-multipart-parser.version>
<postgresql.version>42.2.4</postgresql.version>
<quartz.version>2.3.0</quartz.version>
<querydsl.version>4.1.4</querydsl.version>
<rabbit-amqp-client.version>5.1.2</rabbit-amqp-client.version>
<reactive-streams.version>1.0.2</reactive-streams.version>
<reactor-bom.version>Bismuth-SR10</reactor-bom.version>
<rest-assured.version>3.0.7</rest-assured.version>
<rxjava.version>1.3.8</rxjava.version>
<rxjava2.version>2.1.16</rxjava2.version>
<rxjava-adapter.version>1.2.1</rxjava-adapter.version>
<selenium.version>3.9.1</selenium.version>
<selenium-htmlunit.version>2.29.3</selenium-htmlunit.version>
<sendgrid.version>4.1.2</sendgrid.version>
<servlet-api.version>3.1.0</servlet-api.version>
<simple-json.version>1.1.1</simple-json.version>
<slf4j.version>1.7.25</slf4j.version>
<snakeyaml.version>1.19</snakeyaml.version>
<solr.version>6.6.5</solr.version>
<spring.version>5.0.8.RELEASE</spring.version>
<spring-amqp.version>2.0.5.RELEASE</spring-amqp.version>
<spring-batch.version>4.0.1.RELEASE</spring-batch.version>
<spring-cloud-connectors.version>2.0.2.RELEASE</spring-cloud-connectors.version>
<spring-data-releasetrain.version>Kay-SR9</spring-data-releasetrain.version>
<spring-hateoas.version>0.25.0.RELEASE</spring-hateoas.version>
<spring-integration.version>5.0.7.RELEASE</spring-integration.version>
<spring-kafka.version>2.1.8.RELEASE</spring-kafka.version>
<spring-ldap.version>2.3.2.RELEASE</spring-ldap.version>
<spring-plugin.version>1.2.0.RELEASE</spring-plugin.version>
<spring-restdocs.version>2.0.2.RELEASE</spring-restdocs.version>
<spring-retry.version>1.2.2.RELEASE</spring-retry.version>
<spring-security.version>5.0.7.RELEASE</spring-security.version>
<spring-session-bom.version>Apple-SR4</spring-session-bom.version>
<spring-ws.version>3.0.3.RELEASE</spring-ws.version>
<sqlite-jdbc.version>3.21.0.1</sqlite-jdbc.version>
<statsd-client.version>3.1.0</statsd-client.version>
<sun-mail.version>1.6.1</sun-mail.version>
<thymeleaf.version>3.0.9.RELEASE</thymeleaf.version>
<thymeleaf-extras-data-attribute.version>2.0.1</thymeleaf-extras-data-attribute.version>
<thymeleaf-extras-java8time.version>3.0.1.RELEASE</thymeleaf-extras-java8time.version>
<thymeleaf-extras-springsecurity4.version>3.0.2.RELEASE</thymeleaf-extras-springsecurity4.version>
<thymeleaf-layout-dialect.version>2.3.0</thymeleaf-layout-dialect.version>
<tomcat.version>8.5.32</tomcat.version>
<unboundid-ldapsdk.version>4.0.6</unboundid-ldapsdk.version>
<undertow.version>1.4.25.Final</undertow.version>
<versions-maven-plugin.version>2.3</versions-maven-plugin.version>
<webjars-hal-browser.version>3325375</webjars-hal-browser.version>
<webjars-locator-core.version>0.35</webjars-locator-core.version>
<wsdl4j.version>1.6.3</wsdl4j.version>
<xml-apis.version>1.4.01</xml-apis.version>
<xml-maven-plugin.version>1.0.2</xml-maven-plugin.version>
<xmlunit2.version>2.5.1</xmlunit2.version>
</properties>