Spring is the world’s most popular Java framework, it is widely used to help developers write Java programs in a faster and easier way, but its configuration always was a total nightmare.
Spring Boot makes it easy to create stand-alone, production-grade Spring based Applications that you can “just run”
The whole idea of this module is based on the concept of the RAD (Rapid Application Development) model. It provides a set of default configuration values, and make use of them favoring the automatic setup of a new application
Because of this, the configuration needed to start a Spring application using Spring Boot is minimal, and this helps developers to get started with minimum fuss.
Among the features provided by Spring Boot we have:
- Absolutely no code generation and no requirement for XML configuration
- Provide opinionated ‘starter’ dependencies to simplify your build configuration
- Automatically configure Spring and 3rd party libraries whenever possible
- Provide production-ready features such as metrics, health checks, and externalized configuration
- Create stand-alone Spring applications
- Embed Tomcat, Jetty or Undertow directly (no need to deploy WAR files)
Creating a Project
To create a project in Spring Boot we can make use of the Spring Boot command-line interface or the Spring Initializr tool. There’s a web version of the Spring Initializr in https://start.spring.io
For setting up the project we must provide the following information:
Once we provide all the configuration information we must select the dependencies we’ll use.
Dependencies in Spring Boot comes in bundles, for example, the web dependency will set up Spring MVC and embed an internal servlet engine (Tomcat by default).
You can search for the desired dependencies, and once you have added them you can generate the project. A zip file we’ll be downloaded containing the created project. You can, then, unzip it and open it using your preferred IDE and, without having to configure anything, start the development of your application.
If the selected packaging is Jar, your application will contain a class with a main method, from which you can run it using an embedded Tomcat Server.
To check the result you must then go to your browser and go to the url: http://localhost:8080
On it you’ll see a result similar to this, indicating that your application is missing any mapping for an error path. Your application is already configured and ready to be developed.