Learnerslesson
   JAVA   
  SPRING  
  SPRINGBOOT  
 HIBERNATE 
  HADOOP  
   HIVE   
   ALGORITHMS   
   PYTHON   
   GO   
   KOTLIN   
   C#   
   RUBY   
   C++   




Spring Boot - Starters


Say for example you want to design a Spring application that deals with database or you want to design a web application in Spring.


To achieve that you would need a lot of configuration in the maven file.


But thanks to the spring starter provided by Spring Boot, which takes care most of the configuration in the Maven File.


What is Spring Boot Starter?


As said, the bigger your project is, the tougher is the dependency management.


Note : Don't get panicked by the term dependency management. We will understand it eventually.

So as your project grows, you need to add more dependencies in your pom.xml file. And this is exactly where the starter by Spring Boot comes for rescue.


Spring Boot Starter groups a bunch of dependencies in a single dependency.


Sounds tough?


Let us make it simple.


Say for example, you need to create a Web Project in Spring. In that case you need the below dependencies.

  1. Spring MVC Dependency



    The dependency for spring MVC looks like the below one.

    <dependency>
    	<groupId>org.springframework</groupId>
    	<artifactId>spring-webmvc</artifactId>
    	<version>${org.springframework.version}</version>
    </dependency>

  2. Spring Web dependency


  3. Jackson Dependency


  4. REST Dependency


  5. Tomcat Dependency


Now, as promised we will be using only one starter dependency called spring-boot-starter-web, that would add all the dependencies need for spring web.


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

And it would add all the above dependencies (i.e. Spring MVC Dependency, Spring Web, Jackson, REST and Tomcat)


Similarly, for testing, spring boot provides a starter dependency(Also called maven spring boot starter),


<dependency>
	<groupId>org.springframework.boot</groupId>
	<artifactId>spring-boot-starter-test</artifactId>
	<version>3.0.0</version>
	<scope>test</scope>
</dependency>

This maven starter dependency for testing would include,

  1. Spring Test Dependency


  2. Spring Core


  3. Mockito Dependency


  4. Hamcrest Dependency


  5. JUnit


    Note : You might not be understanding all the dependencies specified above. Just keep a note of it.

Similarly for spring data jpa(i.e. To work with databases), spring boot also provides a starter pack for spring boot data jpa.


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

This starter dependency for data jpa would include,

  1. Spring Data JPA with Hibernate Dependency

  2. Entity Manager Dependency

  3. JDBC Dependency

  4. Transaction API Dependency

  5. Aspects Dependency

  6. Spring Data JPA Dependency


So, we have seen three starter dependency provided by Spring Boot,

  1. spring-boot-starter-web


  2. spring-boot-starter-test


  3. spring-boot-starter-data-jpa


That makes our life a lot easier by including bunch of dependencies by adding just one dependency.