Let's see how to set up a Spring Boot workspace to create a Spring Boot application. No special tool integration is required to set up a Spring Boot application. You can use any IDE or text editor. But, Spring Boot 2.0's minimum system requirements are as follows:
- Java SDK v1.8 or higher
- Spring Framework 5.0.0.RELEASE or above
- Maven (3.2+) and Gradle 4
- Tomcat 8.5, that is, a Servlet 3.0+ compatible container
Let's see the following ways to set up the workspace for the Spring Boot application:
- Set up Spring Boot with Maven
- Set up Spring Boot with Gradle
Now, we will explore how to set up a Spring Boot application with Maven and Gradle in detail.
Spring Boot is compatible with Apache Maven 3.2 or above. If your machine doesn't already have Java 8 or above, first download Java 8 or above from Oracle's official website:
http://www.oracle.com/technetwork/java/javase/downloads/jdk8-downloads-2133151.html
And if you don't already have Maven, first download it from https://maven.apache.org/; Ubuntu users can run sudo apt-get install maven
. Let's see the following Spring Boot dependencies with the org.springframework.boot
groupId:
<?xml version="1.0" encoding="UTF-8"?> <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> <modelVersion>4.0.0</modelVersion> <parent> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-parent</artifactId> <version>2.0.2.RELEASE</version> <relativePath/> <!-- lookup parent from repository --> </parent> <dependencies> <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-web</artifactId> </dependency> </dependencies> ... ... </project>
This .pom
file is the minimum requirement for the Spring Boot 2.0 application.
Let's see the Gradle setup for the Spring Boot application.
We have seen that Java 8 is the minimum requirement for Spring Boot 2.0, both with Maven and Gradle. However, if you want to use Gradle, then first install Gradle 4 or above in your machine from www.gradle.org/.
Now, see the following Gradle Spring Boot dependencies file with org.springframework.boot
groupId. Here's what the build.gradle
file should look like:
buildscript { repositories { jcenter() maven { url 'http://repo.spring.io/snapshot' } maven { url 'http://repo.spring.io/milestone' } } dependencies { classpath 'org.springframework.boot:spring-boot-gradle-plugin:2.0.0.M7' } } apply plugin: 'java' apply plugin: 'org.springframework.boot' apply plugin: 'io.spring.dependency-management' jar { baseName = 'HelloWorld' version = '0.0.1-SNAPSHOT' } repositories { jcenter() maven { url "http://repo.spring.io/snapshot" } maven { url "http://repo.spring.io/milestone" } } dependencies { compile("org.springframework.boot:spring-boot-starter-web") testCompile("org.springframework.boot:spring-boot-starter-test") }
The preceding Gradle file has minimum requirements for the Spring Boot application. You could use either Maven or Gradle since the process is the same. Spring Boot creates an application using the same process.
Let's create your first Spring Boot application and see how to set up the project's structure using Spring Boot Initializr.