Spring Boot – Starters

Spring boot Starters make the development of Spring Boot based Java Applications much faster and easier. It automatically downloads the maven dependencies as well as pre-defined setups. Thus, it makes the developer’s job easy by preventing the manual selection of the right dependencies / versions.

The following tutorial explains more details on the advantages of using Starters.

Spring Boot supports a wide range of starters in order to quickly make the application up and running.

For example, If we need to create a Spring Boot Project with REST Service Support, there is a starter available. Similarly, If we need to add caching support to our project, there is a starter available. Also, if we need to make Spring Boot application persist data into a database using Spring Data JPA with Hibernate, there is a Starter available for that. In short, there is a starter available for almost any kind of application functionality.

  • Consider the following example, that is by adding spring-boot-starter-data-jpa” dependency in the pom.xml, it automatically downloads the following:
    • Spring dependencies
    • JPA libraries for Database access

Refer following code snippet on how to add “spring-boot-starter-data-jpa” dependency into your application:

<dependency>
    <groupId>org.springframework.boot</groupId>
    <artifactId>spring-boot-starter-data-jpa</artifactId>
</dependency>
  • Typically, the starters are categorized into the following:
    • Application Starters,
    • Production Starters, and
    • Technical Starters

All Spring Boot provided starters use the following naming pattern:

spring-boot-starter-* where * is a particular type of application.

This naming structure is intended to help when you need to find a starter. For example, with the appropriate Eclipse or STS plugin installed, you can press ctrl-space in the POM editor and type “spring-boot-starter” for a complete list.

Application Starters

As the name suggests, these following starters provide various application-level functionality features.

The following are a few application starters that are provided by Spring Boot under the org.springframework.boot group:

Refer to the following table:

Starter NameFunctionality of Starter
spring-boot-starterCore starter. For example, auto-configuration support, logging, and YAML support is provided.
spring-boot-starter-jpaStarter for using Spring data JPA along with hibernate.
spring-boot-starter-webStarter for building web, for instance, applications using MVC.
spring-boot-starter-testStarter for testing Spring boot applications with libraries. In addition, it supports JUnit, Hamcrest, and Mockito.
spring-boot-starter-mailStarter for using Java Mail and Spring Framework’s email sending support.

Production Starters

In addition to Application Starters, these Starters provides support for getting production-ready features into Spring boot application. Thus, it helps the developer for debugging purposes.

For example, these are used for monitoring your application and gathering live statistics. Refer the following starter:

Starter NameFunctionality of Starter
spring-boot-starter-actuatorProvides production-ready features. Therefore, it helps to monitor and manage your application.

Technical Starters

The following section gives an overview of Technical Starters that are used to exclude/swap certain default dependencies.

For instance, the default embedded container provided by Spring Boot for Spring web MVC application is Tomcat container, if we want to override this default setting, we can do it using the Technical starters provided by Spring Boot.

As an example, refer the following snippet on how the default dependency (Tomcat) is excluded and a new dependency(Jetty) is included.

<dependency>
    <groupId>org.springframework.boot</groupId>
    <artifactId>spring-boot-starter-web</artifactId>
<!--Exclude the default tomcat starter dependency -->    
<exclusions>
        <exclusion>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-tomcat</artifactId>
        </exclusion>
    </exclusions>
</dependency>
<!--Include the jetty starter dependency -->
<dependency>
    <groupId>org.springframework.boot</groupId>
    <artifactId>spring-boot-starter-jetty</artifactId>
</dependency>

The following table gives an overview of some of the important Technical starters:

Starter NameFunctionality of Starter
spring-boot-starter-tomcatStarter for using Tomcat as the embedded servlet container. In addition, this is the default servlet container starter used by spring-boot-starter-web.
spring-boot-starter-undertowStarter for using Undertow as the embedded servlet container and is an alternative to spring-boot-starter-tomcat.
spring-boot-starter-jettyStarter for using Jetty as the embedded servlet container and is another alternative to spring-boot-starter-tomcat.

[vc_row][vc_column width=”2/3″][td_block_text_with_title custom_title=”Conclusion”][/td_block_text_with_title][/vc_column][/vc_row]

As part of this tutorial, we have learnt about the importance of Starters as well as its usage in a Spring Boot application.

To sum up, Starters are useful for faster development, reduce complexity in pom and auto-download dependencies.

There are more than 30 Spring boot starters. However, we have covered the main starters used in the projects generally. Refer the following link in the references section to see the complete list of starters.

[vc_row][vc_column width=”2/3″][td_block_text_with_title custom_title=”References”][/td_block_text_with_title][/vc_column][/vc_row]

Refer the following section from Spring documentation :

Using Starters

Translate »