Friday, 28 December 2018

Spring Boot Starters

          In previous post, we discussed how to create the Spring boot application using Spring Intializr. In the current post, we will learn the need of spring boot starters and what are the spring boot starters.

     Starters are a set of convenient dependency descriptors that you can include in your application. You get a one-stop-shop for all the Spring and related technology that you need, without having to hunt through sample code and copy paste loads of dependency descriptors. (Reference :-Spring Doc)

    Spring Boot Starters are just JAR Files. They are used by Spring Boot Framework to provide Automatic Dependency Resolution . It means it will add the convenient dependencies for the application. All starters in spring boot start with spring-boot-starter- .  You can also create your own starter but it shouldn't start with spring-boot-starter-, give some other convenient name(Create Own Starter).

    For example, if you want to get started using Spring and JPA for database access, include the spring-boot-starter-data-jpa dependency in your project. Automatically it will add all the required dependencies for jpa to access the database. 


List of Spring boot starters


1)  spring-boot-starter


This starter contains core starter, including auto-configuration support, logging and YAML.

Add this starter into pom.xml, check the below pom.xml.

<dependencies>
     <dependency>  
         <groupId>org.springframework.boot</groupId>
         <artifactId>spring-boot-starter</artifactId>
    </dependency>
</dependencies>



2) spring-boot-starter-web

    Starter for building web, including RESTful, applications using Spring MVC. Uses Tomcat as the default embedded container.

pom.xml,(to add this starter)

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



3) spring-boot-starter-data-jpa

This starter is used to access database for Spring and JPA.

pom.xml,

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


4) spring-boot-starter-jdbc

This Starter for using JDBC with the HikariCP connection pool.

pom.xml,

<dependencies>
     <dependency>  
         <groupId>org.springframework.boot</groupId>
         <artifactId>spring-boot-starter-jdbc</artifactId>
    </dependency>
</dependencies>



5) spring-boot-starter-data-ldap

This Starter for using Spring Data LDAP.

pom.xml,

<dependencies>
     <dependency>  
         <groupId>org.springframework.boot</groupId>
         <artifactId>spring-boot-starter-data-ldap</artifactId>
    </dependency>
</dependencies>


6) spring-boot-starter-data-mongodb

This Starter for using MongoDB(NoSQL database) and Spring Data MongoDB.

pom.xml,

<dependencies>
     <dependency>  
         <groupId>org.springframework.boot</groupId>
         <artifactId>spring-boot-starter-data-mongodb</artifactId>
    </dependency>
</dependencies>



7) spring-boot-starter-security

This starter is using for spring security, to achieve authentication and authorization.

pom.xml,

<dependencies>
     <dependency>  
         <groupId>org.springframework.boot</groupId>
         <artifactId>spring-boot-starter-security</artifactId>
    </dependency>
</dependencies>



8) spring-boot-starter-cache

This starter for using Spring Framework’s caching support.

pom.xml,

<dependencies>
     <dependency>  
         <groupId>org.springframework.boot</groupId>
         <artifactId>spring-boot-starter-cache</artifactId>
    </dependency>
</dependencies>


9) spring-boot-starter-json

This starter is for reading and writing json data.

pom.xml,

<dependencies>
     <dependency>  
         <groupId>org.springframework.boot</groupId>
         <artifactId>spring-boot-starter-json</artifactId>
    </dependency>
</dependencies>



10) spring-boot-starter-test

Starter for testing Spring Boot applications with libraries including JUnit and Mockito.

pom.xml,

<dependencies>
     <dependency>  
         <groupId>org.springframework.boot</groupId>
         <artifactId>spring-boot-starter-test</artifactId>
    </dependency>
</dependencies>


11) spring-boot-starter-validation

Starter for using Java Bean Validation with Hibernate Validator.

pom.xml,

<dependencies>
     <dependency>  
         <groupId>org.springframework.boot</groupId>
         <artifactId>spring-boot-starter-validation</artifactId>
    </dependency>
</dependencies>

       There are so many other starters also available in spring boot, i have not mentioned here.  Only some of important starters listed above. For other starters you can refer Spring documentation.


Note:- As a developer, I would not need to worry about either these dependencies or their compatible versions.


Related Post:--
1) The @SpringBootApplication Annotation usage and example
2) Advantages of Spring Boot
3) How to create the Spring Boot Project using Spring Initializr tool ?
4) Causes and Solution of NoSuchBeanDefinitionException in Spring.

No comments:

Post a Comment