Spring Boot is an opinionated view of the spring ecosystem and third-party libraries. It helps you to create stand-alone, production-grade Spring-based Applications that you can just run.
Spring Boot lets you create Java applications that can run by using java -jar or traditional war deployments. It also provides a command-line tool that runs “spring scripts” with minimum fuss.
Here are some important reasons you should use spring boot.
- Most importantly, Developers can kick start their projects with ease.
- Being opinionated out of the box, solutions are readily available. But the developers can easily override the default flow as requirements come.
- It comes with non-functional features such as embedded servers, security, metrics, health checks, and externalized configuration.
- No XML configuration or Code Generation required.
How to set up Spring Boot?
Even though we can set up Spring Boot projects from scratch, it is better to use build tools like Maven or Gradle. This way, we could ensure that the project follows some structure. For this reason, there are a couple of standard ways you can set up your development environment. So let’s go through each of them.
Using Spring Initializer
The Spring Initializer is an online tool that lets you create spring boot projects. In this tool, you must provide the details like,
- Maven or Gradle project
- Java/Kotlin or Groovy-based project?
- Project information like group, artifact and optional details like name and description.
- Whether the project would be packaged in JAR or WAR.
- Which Java version to use
- And finally, the dependencies(starters) that your project wants to use.
The downloaded file will be a zip file with a proper structure that you can simply run using Maven or Gradle goals. You could also import these projects into your favorite IDEs.
Setting up Spring Boot in IDEs
Most modern IDEs support Spring boot out of the box or through plugins. For example, IntelliJ Idea Ultimate has a dedicated new project option for this type.
Similarly, Spring Tool Suite, an eclipse based tool also provides similar UI.
Also there are other IDEs like VSCode and Eclipse provide similar options based on plugins. But the above are the most common ways developer set up their projects locally.
With all of these options, you end up with a project in your IDE, To run this project, you could execute
mvn spring-boot:run. For Gradle projects, you shall run
gradle bootRun. Surprisingly both of these commands will work out of the box.
With that being said, You should start with the hello world spring boot web application to learn more.