Get an Introduction to Spring Boot. Learn framework features and basic concepts in detail and understand benefits of Using Spring Boot.
This is first tutorial of our Spring Boot Learning Series. Therefore, we will try to understand ‘What is Spring Boot?’ and some of its major features before we dig deeper.
What is Spring Boot?
Spring Boot is a java-framework, based on top of Spring Framework. Which makes it easy to create Spring backed applications quickly with and with less configurations.
Spring Boot is yet another popular Spring project. In 2012, there was a feature request to enable container-less applications using Spring Framework. The Spring Developers developed an entire framework around the feature request, and named it as Spring Boot (2014).
To run Spring-Boot you don’t 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 which bootstraps spring boot components, container and other framework components.
Why Spring Boot?
We are in the world of cloud computing. Where, we love to focus on the core business. While, we delegate the logistics to the expert service providers. For Example, Cloud or various ‘as a service tools. Because, intention is to save time and cost.
Similarly, the services or micro-services are developed and maintain in agile manner. 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 is taking 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 certain configuration is provided, it will be used. However, If a configuration is not provided Spring will replace with default and proceed.
Life without Spring Boot
To understand Spring Boot benefits, let’s first understand how to 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 bunch of starter dependencies. These starter dependencies are part of Spring IO platform. All the starter dependencies start with word
spring-boot-starter-*. For example
The starter dependencies are like one stop shop for all your dependencies. You don’t 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 current Spring Boot version.
This was an Introduction to Spring Boot. Spring Boot enables 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.
This was the first chapter of our ongoing series of Learning Spring Boot. Stay Tuned.