Spring Boot – Build Systems

In Spring Boot, choosing a build system is an important task. We recommend Maven or Gradle as they provide a good support for dependency management. Spring does not support well other build systems.

1. Dependency Management

Spring Boot team provides a list of dependencies to support the Spring Boot version for its every release. You do not need to provide a version for dependencies in the build configuration file. Spring Boot automatically configures the dependencies version based on the release. Remember that when you upgrade the Spring Boot version, dependencies also will upgrade automatically.

Note − If you want to specify the version for dependency, you can specify it in your configuration file. However, the Spring Boot team highly recommends that it is not needed to specify the version for dependency.

2. Maven Dependency

For Maven configuration, we should inherit the Spring Boot Starter parent project to manage the Spring Boot Starters dependencies. For this, simply we can inherit the starter parent in our pom.xml file as shown below.

<parent>
   <groupId>org.springframework.boot</groupId>
   <artifactId>spring-boot-starter-parent</artifactId>
   <version>1.5.8.RELEASE</version>
</parent>

We should specify the version number for Spring Boot Parent Starter dependency. Then for other starter dependencies, we do not need to specify the Spring Boot version number. Observe the code given below −

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

3. Gradle Dependency

We can import the Spring Boot Starters dependencies directly into build.gradle file. We do not need Spring Boot start Parent dependency like Maven for Gradle. Observe the code given below −

buildscript {
   ext {
      springBootVersion = '1.5.8.RELEASE'
   }
   repositories {
      mavenCentral()
   }
   dependencies {
      classpath("org.springframework.boot:spring-boot-gradle-plugin:${springBootVersion}")
   }
}

Similarly, in Gradle, we need not specify the Spring Boot version number for dependencies. Spring Boot automatically configures the dependency based on the version.

dependencies {
   compile('org.springframework.boot:spring-boot-starter-web')
}

Related posts:

Jackson vs Gson
Marker Interface trong Java
Exploring the Spring 5 WebFlux URL Matching
HTTP Authentification and CGI/Servlet
Loại bỏ các phần tử trùng trong một ArrayList như thế nào trong Java 8?
Test a REST API with Java
Comparing Long Values in Java
Java Program to Implement Interval Tree
Guide to Spring 5 WebFlux
Java 8 Streams peek() API
Java Program to Implement Quick Hull Algorithm to Find Convex Hull
Java Program to Give an Implementation of the Traditional Chinese Postman Problem
Java Program to Search for an Element in a Binary Search Tree
Limiting Query Results with JPA and Spring Data JPA
Java Program to Check Whether an Input Binary Tree is the Sub Tree of the Binary Tree
Introduction to Spring MVC HandlerInterceptor
Create Java Applet to Simulate Any Sorting Technique
Java Program to Implement Segment Tree
Java Program to Evaluate an Expression using Stacks
Java Copy Constructor
Spring WebClient Requests with Parameters
Java Program to Implement Weight Balanced Tree
Spring Boot - Enabling Swagger2
Java Program to Implement Aho-Corasick Algorithm for String Matching
Java Program to Emulate N Dice Roller
Vấn đề Nhà sản xuất (Producer) – Người tiêu dùng (Consumer) và đồng bộ hóa các luồng trong Java
Java Program to Find MST (Minimum Spanning Tree) using Prim’s Algorithm
Practical Java Examples of the Big O Notation
Spring Boot - Database Handling
Spring 5 Testing with @EnabledIf Annotation
Java Program to Implement Bresenham Line Algorithm
Java Program to Find Whether a Path Exists Between 2 Given Nodes