Spring Boot Dependency Management - spring-boot-starter-parent

All spring boot application uses the spring-boot-starter-parent as the parent in pom.xml like below. It is a special project, the provides default configuration for our application (Java version and other properties),   complete dependency tree to quickly build our spring boot project and default plugin configurations (maven-failsafe-plugin, maven-jar-plugin etc..).
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>2.3.3.RELEASE</version>
<relativePath/> <!-- lookup parent from repository -->
</parent>
Once we declared the starter parent in our project, we can just pull any dependencies from the parent by just declaring it our dependencies tag, and also we don't need to define versions of the dependencies. Maven will download jar files based on the version defined for starter parent in the parent tag. If you want different dependency version of the jar other than the default one provided by the starter parent, you can explicitly define the version in the dependency management section.
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-rest</artifactId> <!-- if you want to override the default version add the version tag -->
<version>2.1.1.RELEASE</version>
</dependency>
If you want to change the property defined in the starter parent like (java version, source encoding etc..), we can redeclare it in our properties section.

<properties>
<java.version>11</java.version>
</properties>
Happy Programming...!!!

Comments

Popular posts from this blog

Method Reference in Java Streams

PHP LARAVEL Directory Structure

PHP LARAVEL - Hello World Laravel