Get an introduction to Spring Boot. Learn framework features and basic concepts in detail and understand the benefits of Using Spring Boot.
This tutorial is the first of our Spring Boot Learning Series. Therefore, we will try to understand ‘What is Spring Boot?’ and some of its powerful features before jumping into their details.
What is Spring Boot?
Spring Boot is a Java framework based on top of Spring Framework. That makes it easy to create Spring backed applications quickly and with fewer configurations.
Spring Boot is yet another popular Spring project. In 2012, a feature request was to enable container-less applications using Spring Framework. The Spring Developers developed an entire framework around the feature request and named it Spring Boot (2014).
To run Spring-Boot, you do not need to deploy the project into a Container. Because Spring Boot comes with an inbuilt container and each application has one. Similarly, each Spring Boot application has a main method that bootstraps spring boot components, containers, and other framework components.
Why Spring Boot?
We are in cloud computing, where we love to focus on the core business and save time and cost. Thus, we delegate the logistics to the expert service providers—for Example, Cloud or various ‘as a service tool.
Similarly, the services or micro-services are developed and maintained agilely. That is why we want them to be lightweight and focused. Therefore, we love using Spring Boot. Applications can freely focus on the business while Spring Boot takes care of the rest.
Spring Boot has defaults for almost everything. However, it still lets you to chose what to configure. For Instance, If a specific configuration is present, it will be used. However, Spring will replace with default if a configuration is not provided and proceed.
Life without Spring Boot
To understand Spring Boot benefits, let us first understand how we write and deploy applications without Spring Boot.
- Project Dependencies: Dependency management is a big pain. Especially, when we upgrade certain libraries. We often face compatibility issues.
- Project Configurations: All spring projects require XML or annotation based configurations. For instance, Right from setting up a datasource or a JMC subscriber we have to initialise each and every component on our own.
- Environments: Managing the environment variables is a pain. Things like database connections, passwords are stored locally on the environments and detached from the actual application.
- Container: We need to find and download a container of choice. In addition, we also need to configure the container on the box. For example, security, port and context etc.
- Deployment: The application needs to be packaged and deployed into the container residing on the box.
- Faster Development: Let it be a POC, a Production grade application or a Learning project, Spring Boot cuts-off the initial setup, development, and deployment time. Because, Spring Boot is capable of running on minimal configurations and gives a hassle free development experience.
- Spring Boot is Opinionated: Spring Boot is smart, if you don’t provide certain configurations, Spring Boot uses defaults and starts. For instance, even if you don’t provide a database driver and respective configurations, Spring Boot will start with an in-memory database. However, when you provide your own configurations, Spring Boot will respect it and take out the auto-configurations for the respective components.
- Production Ready: Spring Boot application are bootstrapped from the
mainmethod. The way you run a Spring Boot application locally is the same as you do for a Production Box. In addition, having Strong properties management mechanism provides a structured way to externalise environment specific properties making it easy to deploy the same
jarto any box. It only needs
JREto run a Spring Boot Application.
- In-built Container: No need to deploy application archive to any external containers and configure the servers. Spring Boot has inbuilt tomcat which is bootstrapped from applications
mainmethod. Starting the whole application is as simple as
- Version Management: Spring Boot uses spring.io platform for the version compatibility. Which means we just need to specify the Spring Boot version we want to use and Spring will find and install compatible libraries on its own.
- Actuators: Visit our detailed posts on actuators: Spring Boot Actuator with Spring Boot 2 and Spring Boot Actuator in old Spring Boot (1.x).
Spring Boot provides a bunch of starter dependencies. These starter dependencies are part of the Spring IO platform. All the starter dependencies start with the word
spring-boot-starter-*. For example
The starter dependencies are like a one-stop-shop for all your dependencies. You do not need to identify and put the compatible dependencies for all the various tools used in your project. For example, adding dependency of
spring-boot-starter-data-mongodb will download all the required dependencies compatible with the current Spring Boot version.
That was an introduction to Spring Boot. Spring Boot enables a faster way to develop and get your application to Production. Spring Boot has a feature of auto-configuration, which helps start an application with minimal configurations.
Recommended Spring Boot Tutorials on Our Site
- Spring Boot Introduction (This Post)
- Change Default Port in Spring Boot Application
- Configure Spring Boot Embedded Tomcat Server
- Spring Boot Application in Embedded Jetty Server
- Spring Boot Auto Configuration
- Spring Boot Runners – ApplicationRunner and CommandLineRunner
- How to Change Context Path in Spring Boot
- How to use Spring Profiles – Tutorial with Examples
- Spring Boot Actuator with Spring Boot 2
- Actuator in old Spring Boot (1.x)
- Custom Health Check in Spring Boot Actuator
- How to Secure Spring Boot Actuator Endpoints
- Introduction to Spring Boot Admin Server with Example
- How to Write Your Own Spring Boot REST Service (Most Read)
- CRUD REST Service With Spring Boot, Hibernate, and JPA
- How to Write a non-web Application with Spring Boot
- Spring Rest Service Exception Handling
- Enable Spring Boot ApplicationStartup Metrics to Diagnose Slow Startup
- Spring Boot with Spring Data JPA
- Spring Data JPA Composite Key with @EmbeddedId (Most Read)
- Wildcard Queries with Spring Data JPA
- Spring Data JPA find by @EmbeddedId Partially
- Pagination and Sorting with Spring Data JPA (Most Read)