Spring Boot is a popular Java-based framework used for developing web applications and microservices. It is developed by Pivotal and is available under the Apache License 2.0.
Spring Boot makes it easy to create stand-alone, production-grade Spring-based applications that you can "just run." It takes an opinionated view of the Spring platform and third-party libraries so that you can get started with minimum fuss. Most Spring Boot applications need very little Spring configuration.
There are many reasons to use Spring Boot when developing your next project, Here are some of the most important ones:
In this section, we'll show you how to get started with Spring Boot. We'll begin by creating a new Spring Boot project using the Spring Initializr. The Spring Initializr is a web-based tool that makes it easy to create a new Spring Boot project.
To create a new Spring Boot project, you can use the Spring Initializr web tool. Go to the Spring Initializr website and select the following options:
Gradle Project
Java
2.1.3
com.example
myproject
My Project
A simple Spring Boot project
com.example.myproject
Jar
8
Web
Click the "Generate Project" button to download a zip file containing your new Spring Boot project.
Spring Tool Suite (STS) is a popular IDE for developing Spring-based applications. In this section, we'll show you how to import the project into STS.
Start STS and go to File
-> Import...
. Select Gradle Project
from the list of options and click Next
.
Browse to the location of the project you downloaded from the Spring Initializr and click Finish
.
STS will import the project and create a project structure similar to the following:
myproject
├── src
│ └── main
│ ├── java
│ │ └── com
│ │ └── example
│ │ └── myproject
│ │ └── Application.java
│ └── resources
│ ├── application.properties
│ └── static
│ └── index.html
├── build.gradle
└── settings.gradle
You can run the application from the command line using the gradlew
command:
$ ./gradlew bootRun
You can also run the application from your IDE. In STS, you can right-click on the Application.java
file and select Run As
-> Spring Boot App
.
When the application is running, you can access the front page at http://localhost:8080/.
In this article, we've shown you how to get started with Spring Boot. We've created a new project using the Spring Initializr and imported it into our IDE. We've also shown you how to run the application.