Spring Boot - Starter Parent - GeeksforGeeks (2024)

Improve

Spring Boot Starter Parent is a starter project that provides the default configuration for spring-based applications. It is added as a parent in the pom.xml file. The spring-boot-starter-parent defines spring-boot-dependencies as its parent. The spring-boot-starter-parent inherits dependency management from spring-boot-dependencies. Every Spring Boot release provides a list of dependencies and the latest versions it supports. The dependency management feature of the starter parent allows the common dependencies to omit the <version> tag in the pom.xml file. If a dependency requires a specific version other than the version configured by the starter parent, that can be added using the <version> tag. The following are the features of the starter parent project:

  • The dependency management feature manages the versions of common dependencies.
  • Provide the default compiler level as Java 1.8 and UTF-8 source encoding.
  • Provides a default configuration for Maven plugins such as maven-surefire-plugin, maven-jar-plugin, and maven-failsafe-plugin.
  • Executes a repackage goal with a repackage execution id.
  • Resource filtering and configuring profile-specific files.

The parent of spring-boot-starter-parent looks like the following

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

The following code has to be added in the pom.xml to use spring-boot-starter-parent as a parent project.

<parent> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-parent</artifactId> <version>2.5.2</version> <!-- spring boot version number --> <relativePath/> <!-- lookup parent from repository --></parent>

Managing dependencies

Any spring boot starter can be included under the dependencies section. If we omit the version for a particular starter, Maven will download the jar files based on the version number defined in the parent section. For example, if we require a data access layer, then we should add spring-data-jpa dependency starter in the pom.xml file.

<dependencies> <dependency> <groupId>org.springframework.data</groupId> <artifactId>spring-data-jpa</artifactId> </dependency><dependencies>

Dependency Management Tag

If you require a different version of dependency provided by the spring-boot-starter-parent, we can add a particular version inside the <version></version> tag and include the dependency and its version inside the dependencyManagement section.

<dependencyManagement> <dependencies> <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-web</artifactId> <version>2.4.0</version> </dependency> </dependencies></dependencyManagement>

Properties

We know that spring-boot-starter-parent configures the java compiler version, Maven plugins version, and Dependencies version using the properties defined inside it. We can override those property values inside the pom.xml file under the properties section. Suppose our project requires a different version of the sl4j library and a different java version.

<properties> <java.version>1.8</java.version> <slf4j.version>1.7.30</slf4j.version></properties>

Using Spring Boot Without a Starter Parent

If we want to inherit from the custom parent POM or define all the Maven configurations manually, we don’t inherit from the spring-boot-starter-parent pom. However, we can still benefit from the dependency management feature(not the plugin management) provided by spring-boot-dependencies, by including the dependency inside the dependencyMangement section as an import scope.

<dependencyManagement> <dependencies> <dependency> <!-- Import dependency management from Spring Boot --> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-dependencies</artifactId> <version>2.5.2</version> <type>pom</type> <scope>import</scope> </dependency> </dependencies></dependencyManagement>

Note: To override the properties of individual dependencies, we need to add those dependencies prior to the addition of spring-boot-dependencies.


Last Updated : 28 Jul, 2021

Like Article

Save Article

Share your thoughts in the comments

Please Login to comment...

Spring Boot - Starter Parent - GeeksforGeeks (2024)

FAQs

Spring Boot - Starter Parent - GeeksforGeeks? ›

The spring-boot-starter-parent defines spring-boot-dependencies as its parent. The spring-boot-starter-parent inherits dependency management from spring-boot-dependencies. Every Spring Boot release provides a list of dependencies and the latest versions it supports.

What does Spring Boot starter parent do? ›

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.

What is the difference between Spring Boot starter parent and Spring-Boot-starter-web? ›

The spring-boot-starter-parent inherits dependency management from spring-boot-dependencies. And all the other spring boot starters (e.g., spring-boot-starter-web, spring-boot-starter-test, etc.) inherit dependency management and version control from spring-boot-starter-parent.

Is Spring Boot starter parent version compatible with Java 17? ›

Java 17 support has been added to Spring Framework from 5.3. X and Spring Boot 2.5. X. If you need to use Spring Boot with Java 17, then you need to upgrade it to 2.5.

Is spring boot starter parent necessary? ›

The spring-boot-starter-parent is a project starter. It provides default configurations for our applications. It is used internally by all dependencies. All Spring Boot projects use spring-boot-starter-parent as a parent in pom.

What is spring boot starter parent Maven? ›

Spring Boot Starter Parent is a starter project that provides the default configuration for spring-based applications. It is added as a parent in the pom. xml file. The spring-boot-starter-parent defines spring-boot-dependencies as its parent.

What does a Spring Boot starter contain? ›

The starters contain a lot of the dependencies that you need to get a project up and running quickly and with a consistent, supported set of managed transitive dependencies. All official starters follow a similar naming pattern; spring-boot-starter-* , where * is a particular type of application.

What is Spring Boot starter parent gradle? ›

The Spring Boot Gradle Plugin provides Spring Boot support in Gradle. It allows you to package executable jar or war archives, run Spring Boot applications, and use the dependency management provided by spring-boot-dependencies . Spring Boot's Gradle plugin requires Gradle 7. x (7.5 or later) or 8.

Does Spring Boot starter include Tomcat? ›

Many Spring Boot starters include default embedded containers. For servlet stack applications, the spring-boot-starter-web includes Tomcat by including spring-boot-starter-tomcat , but you can use spring-boot-starter-jetty or spring-boot-starter-undertow instead.

Why Spring Boot 3 requires Java 17? ›

You'll need to upgrade to JDK 17 before you can develop Spring Boot 3.0 applications. This means you can take advantage of the latest features and performance improvements that Java 17 offers.

Which JDK is best for spring boot? ›

Spring Boot 3.0 will require Java 17, but you don't need to wait until that release to upgrade to the latest LTS Java version. Any recent Spring Boot 2. x release will work really well with Java 17. You can also make use of Java 17 features (such as records) in your own codebases.

What is spring boot starter parent gradle? ›

The Spring Boot Gradle Plugin provides Spring Boot support in Gradle. It allows you to package executable jar or war archives, run Spring Boot applications, and use the dependency management provided by spring-boot-dependencies . Spring Boot's Gradle plugin requires Gradle 7. x (7.5 or later) or 8.

What is the use of spring boot starter batch? ›

Running Spring Batch Jobs on Startup

Spring Batch auto-configuration is enabled by adding spring-boot-starter-batch to your application's classpath. If a single Job bean is found in the application context, it is executed on startup (see JobLauncherApplicationRunner for details).

What does spring boot starter validation do? ›

Hibernate validator offers validation annotations for Spring Boot that can be applied to the data fields within your Entity class, and allows you to follow specific rules and conditions for fields in which we are applying validators to meet your custom constraints.

Top Articles
Latest Posts
Article information

Author: Tuan Roob DDS

Last Updated:

Views: 6287

Rating: 4.1 / 5 (42 voted)

Reviews: 81% of readers found this page helpful

Author information

Name: Tuan Roob DDS

Birthday: 1999-11-20

Address: Suite 592 642 Pfannerstill Island, South Keila, LA 74970-3076

Phone: +9617721773649

Job: Marketing Producer

Hobby: Skydiving, Flag Football, Knitting, Running, Lego building, Hunting, Juggling

Introduction: My name is Tuan Roob DDS, I am a friendly, good, energetic, faithful, fantastic, gentle, enchanting person who loves writing and wants to share my knowledge and understanding with you.