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.
Tutorial Contents
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).
You don’t need an external container to run a Spring Boot application. That is because Spring Boot comes with an inbuilt container. A Spring Boot application has the ‘public static void main(String[] a)‘ method that bootstraps various Spring Boot beans, inbuilt containers, and other 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 tools.
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.
Learn more:
Life without Spring Boot
To understand Spring Boot’s benefits, let us first understand how we write and deploy applications without Spring Boot.
- Project Dependencies: Dependency management is a significant 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, from setting up a data source or a JMC subscriber, we have to initialize every component.
- Environments: Managing the environment variables is a pain. Things like database connections and passwords are stored locally in 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.
Features
- 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 so smart that if we don’t provide certain configurations, Spring Boot uses defaults. 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 our configurations, Spring Boot will respect them and take out the auto-configurations for the respective components.
- Production Ready: Spring Boot applications are bootstrapped from the main method. How you run a Spring Boot application locally is the same as you do for a Production Box. In addition, having a Strong properties management mechanism provides a structured way to externalise environment-specific properties making it easy to deploy the same jar to any box. It only needs
JRE
to run a Spring Boot Application. - In-built Container: No need to deploy the application archive to any external containers and configure the servers. Spring Boot has an inbuilt tomcat bootstrapped from the application’s main method. Starting the whole application is as simple as ‘java -jar‘.
- Version Management: Spring Boot uses the spring.io platform for version compatibility. This means we need to specify the Spring Boot version we want to use, and Spring will find and install compatible libraries.
- Actuators: Visit our detailed posts on actuators: Spring Boot Actuator with Spring Boot 2 and Spring Boot Actuator in old Spring Boot (1.x).
Starters Dependency
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 prefix ‘spring-boot-starter-*‘. For example, ‘spring-boot-starter-web‘.
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 the dependency of ‘spring-boot-starter-data-mongodb‘ will download all the required dependencies compatible with the current Spring Boot version.
Summary
That was an introduction to Spring Boot. Spring Boot enables a faster way to develop and get your application to Production. Spring Boot has an auto-configuration feature, 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)