Master java skills

Spring Boot Starters

Dependency management is a big problem specially with their versions. In the past, we have seen that if we are using multiple spring or other dependencies, there is always version problems that we have to address. One particular version of spring-context doesn’t work with another version of other spring dependencies and so on.

This version problem has been addressed effectively in spring boot. Spring Boot provides multiple starter kits for specific purpose. These kits bundles all the required dependencies along with their compatible versions together. For example, if we want to develop a spring web based application, we only need to include spring-boot-starter-web dependency. If we want to do testing, then we need to include spring-boot-starter-test dependency, and it will include all the required dependencies for testing.

Spring boot starter parent

This is the project starter. This dependency provides all the default configuration required for our application. All spring boot projects use spring-boot-starter-parent dependency as project parent dependency.

Note -> Please note that there is <version> element there. All spring boot starter dependencies versions are controlled by this parent version of spring boot.

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

Spring boot starter web

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

Spring boot starter test

For testing, we usually use Junit, Hamcrest, Mockito (or any other mocking framework) etc. All these dependencies are bundled into spring-boot-starter-test.

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

Data JPA starter

If we are using persistence, instead of adding dependencies manually, we can use data jpa starter.

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

Mail starter

Similarly, if we have to use mail api, then we can use Mail Starter

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