What is Spring Boot?
Hi, I’m Kishen Deemud. In this article, I will give you an introduction about Spring Boot.
The spring team decided they wanted to provide developers with some utilities which relatively automate the configuration procedures and speeds up the process of building and deploying spring applications, so they invented spring boot.
Spring boot is a utility project which aims to make it easy to build spring-based, production-ready applications and services with minimum fuss. it provides the shortest way to get a spring web application up and running with the smallest line of code/configuration out-of-the-box.
Spring Boot Features
There are a bunch of features specific to spring boot, but three of my favourites are dependency management, auto-configuration, and embedded servlet containers.
1. Easy Dependency Management
In order to speed up the dependency management process, spring boot implicitly packages the required compatible third-party dependencies for each type of spring application and exposes them to the developer using starters.
Starters are a set of convenient dependency descriptors that you can include in your application. you get a one-stop-shop for all the spring and related technology that you need, without having to hunt through sample code and copy-paste loads of dependency descriptors.
For example, if you want to get started using Spring and JPA for database access, just include the spring-boot-starter-data-JPA dependency in your project, and you are good to go (no need to hunt for compatible database drivers and hibernate libraries).
Also, if you want to create a spring web application, just add spring-boot-starter-web dependency, and, by default, this will pull all the commonly used libraries for developing spring MVC applications such as spring-webmvc, jackson-json, validation-api, and tomcat.
In other words, spring boot gathers all the common dependencies and defines them in one place and allows the developer to use them instead of reinventing the wheel each time they create a new application.
Therefore, pom.xml becomes much smaller than the one used with traditional spring applications.
Check the docs to get familiar with all spring boot starters.
2. Auto Configuration
The second awesome feature of spring boot is the auto-configuration.
After you select the appropriate starter, spring boot attempts to automatically configure your Spring application based on the jar dependencies that you have added.
For example, if you add spring-boot-starter-web, spring boot automatically configures the commonly registered beans like dispatcherservlet, resourcehandlers, messagesource.
Also, if you’re using spring-boot-starter-jdbc , spring boot automatically registers the datasource, entitymanagerfactory, and transactionmanager beans and reads the connection details from the application.properties file.
In case you don't intend to use a database and you don't provide any manual connection details, spring boot will auto-configure an in-memory database without any further configuration on your part whenever it finds an h2 or hsql library on the build path.
This is totally configurable and can be overridden anytime by custom configuration.
3. Embedded Servlet Container Support
Each spring boot web application includes an embedded web server by default, check this for the list of embedded servlet containers supported out of the box.
Developers don’t need to worry about setting up a servlet container and deploying the application on it. the application can be run by itself as a runnable jar file using its embedded server.
If you need to use a separate http server, you just need to exclude the default dependencies, spring boot provides separate starters for http servers to help make this process as easy as possible.
Creating standalone web applications with embedded servers is not only convenient for development but also a legitimate solution for enterprise-level applications, and is increasingly useful in the microservices world. Being able to wrap an entire service (for example, user authentication) in a standalone and fully-deployable artefact that exposes an API makes distribution and deployment much quicker and easier to manage.
Spring Boot Requirements
- Setting up and running spring boot applications requires the following:
- Java 8+
- Spring framework 5.0.1 release or above
- Servlet 3.0+ container (in case you don’t make use of the embedded servers).
So I hope you understand my explanation about Spring Boot. Thank you!
Comments
Post a Comment