How to Create a Spring Boot Project
How Spring Boot Works
Spring Boot is a framework that is built on top of the Spring Framework in order to make application development faster and easier.
Spring Boot is designed to automatically configure Spring whenever possible and therefore Spring Boot applications need very little Spring configuration.
Spring Boot uses your classpath and beans that you have configured to add items that your application is missing. With Spring Boot, a developer can focus more on business features and less on infrastructure.
To create a Spring Boot project from scratch, do the following:
- Go to Spring Initializr at https://start.spring.io and fill in your project details as follows:
- Project: Choose Gradle Project or Maven Project.
- Language: Java
- Spring Boot: Latest stable version of Spring Boot is selected by default. So leave it as is.
- Project Metadata: Provide group name in the Group field. The group name is the id of the project. In Artifact field, provide the name of your project. In the package field, provide package name for your project. Next, select your preferred version of Java that is installed on your computer and is available on your local environment.
- Dependencies: Spring provides a number of Spring Starters that allows to add correct compatible version of jars in the classpath of your application. Add all dependencies that your project needs. Dependencies which are not available as Spring Starters can be added later from the project management file (pom.xml for Maven projects and build.gradle file for Gradle projects). In the image below, you'll see that we are creating a new Spring Boot project with dependencies for Spring Web which is needed for building a Spring web application, and Spring Boot DevTools which is needed for quick restart of the application while it is running:
Congratulations, you have learned how to create a simple Spring Boot Project.