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:

So sánh HashMap và Hashtable trong Java
Primitive Type Streams in Java 8
Guide to ThreadLocalRandom in Java
Java Program to Check if a Point d lies Inside or Outside a Circle Defined by Points a, b, c in a Pl...
Java Program to Implement Graham Scan Algorithm to Find the Convex Hull
Java Program to Implement Merge Sort on n Numbers Without tail-recursion
Instance Profile Credentials using Spring Cloud
HttpClient 4 – Send Custom Cookie
Sắp xếp trong Java 8
Spring JDBC
Java String Conversions
Java Program to Perform Finite State Automaton based Search
Java Program to Encode a Message Using Playfair Cipher
Send an email using the SMTP protocol
Guide to CountDownLatch in Java
Java Program to Implement Ford–Fulkerson Algorithm
Java Program to Print only Odd Numbered Levels of a Tree
OAuth2 for a Spring REST API – Handle the Refresh Token in AngularJS
Java Program to Check whether Directed Graph is Connected using BFS
Introduction to Spring Boot CLI
Java Program to Find Transpose of a Graph Matrix
Java Program to Check Whether a Weak Link i.e. Articulation Vertex Exists in a Graph
A Guide to Java 9 Modularity
Transactions with Spring and JPA
How to Kill a Java Thread
Period and Duration in Java
Java Program to Test Using DFS Whether a Directed Graph is Weakly Connected or Not
Spring Boot - Actuator
Loại bỏ các phần tử trùng trong một ArrayList như thế nào?
Guide to Character Encoding
Java Program to Check if a Given Graph Contain Hamiltonian Cycle or Not
Hướng dẫn Java Design Pattern – Factory Method