What is Spring Boot ?, What is Spring Boot in Java?, Features of Spring Boot, A Summary of Spring Boot Framework, What is Spring Boot All About?, Spring Boot Interview Questions, Spring Boot Tutorial etc.
Those who are working in Java or even who just started learning Java programming, must have heard about the term Spring Boot. Those who are preparing for interviews either Freshers or experienced must also learn this term. Many a time interviewers are also asking ‘What is Spring Boot ?’. Nothing more to say how much important it is. Even it is also needless to say, how much importance this term has in a Java Developer’s life.
In this article, we will have a clear picture of What is Spring Boot ?. Moreover, we will also learn the related concepts. Apart from learning What is Spring Boot ?, you will also learn What does Spring boot do?. We have a separate article for Spring Boot Features in detail. Let’s start discussing all about it.
Table of Contents (Click on links below to navigate)
- 1 What is Spring Boot?
- 2 Why is Spring Boot so popular?
- 3 What are the advantages of Spring Boot ?
- 3.1 1) Spring Boot Starters
- 3.2 2) Reducing Boilerplate Code
- 3.3 3) Embedded Servers
- 3.4 4) Easier to connect with Databases
- 3.5 5) Supports development of Microservices
- 3.6 6) Default setup for Testing
- 3.7 7) Run Application as a jar file
- 3.8 8) Spring Boot Profile to easy switch environment
- 3.9 9) Spring Boot Actuator for Application Monitoring
- 3.10 10) Increases Productivity and minimizes Development time
- 4 What are the disadvantages of Spring Boot ?
- 5 How many ways are there to create a Spring Boot Application?
- 6 What are the Starters in Spring Boot ?
- 7 Summary
What is Spring Boot?
Spring Boot is a combination of two words “Spring” and “Boot”. Here, the word ‘Spring’ represents a Spring Application. The word ‘Boot’ represents bootstrap. Hence, Spring Boot is an open-source java-based framework that helps in bootstrapping the Spring Application.
Here is the official definition of spring.io website : “Spring Boot makes it easy to create stand-alone, production-grade Spring based Applications that you can just run”.
Let’s understand it word by word now. Spring Boot simplifies the process of creating a Spring based Application. Now what are the characteristics of the Spring based Application that Spring Boot creates? That application is stand alone, production ready and just runnable. We don’t have to worry about making jar/war and deploying it into any web server. These tasks and configurations are done by Spring Boot internally. Moreover, It has embedded web servers in the form of jar files that internally handle the process of running the application.
Why is Spring Boot so popular?
If we compare with other frameworks in Java programming language, Spring Boot became very popular in a very short duration. For example, below are some points that make Spring Boot a popular framework to develop a production-ready application.
1. Spring Boot speeds up the project development.
2. It provides an easier and faster way to configure, set up & run both web-based as well as simple applications.
3. No web servers like (Tomcat, Jetty, Undertow) are required to configure separately. Therefore, no need to deploy any war file manually.
4. Reduces XML configurations and promotes annotations.
5. Combines more than one annotations of Spring framework & replaces them by introducing a single annotation. For example, @SpringBootApplication is a combination of three annotations : @EnableAutoConfiguration, @Configuration, @ComponentScan
6. Reduces the efforts of developer to deliver an enterprise-level application.
7. Provides ready-made functionalities that are the most common and applicable to any project. Hence, it eliminates boiler plate code.
8. Creates stand-alone application that can be run using jar file.
9. Automatically configures Spring and third party libraries whenever possible.
10. Provides production-ready features such as health checks, metrics and externalized configurations.
11. Provides easy integration mechanism with many third party tools.
12. Spring Boot offers a great support to develop Microservices in Java.
13. Spring Boot Application easily integrates with its ecosystem like Spring JDBC, Spring ORM, Spring Data, Spring Security, Spring Web MVC etc.
14. It integrates with databases very easily. Sometimes, no need to provide database specific properties like driver, dialects etc., as it automatically picks these property values from database URL.
15. It provides developers ready-made starter projects to quickly work on functionalities rather than wasting time in setting up initial configurations.
16. Spring Boot also provides command line interface(CLI) to develop and test applications quickly.
17. It provides support of most commonly used build tools like Maven & Gradle.
What are the advantages of Spring Boot ?
1) Spring Boot Starters
Spring Boot provides us a choice to add ready made mini starter projects to simplify the process of development. We can add them either at the beginning or even in the middle of development. For example, Spring Web, Spring Data JPA, Spring Security, Spring Boot Dev Tools, MySQL Driver, Java Mail Sender, Eureka Server etc. are some of the starter projects. It also provides flexibility to add other third party libraries in the form of starter projects like Lombok.
2) Reducing Boilerplate Code
Spring Boot helps to avoid all the manual work of writing boilerplate code, annotations, and complex XML configurations. It internally consumes Spring framework’s API and provides easy to use API that saves us from writing boilerplate code again & again. Moreover, It also consumes multiple Spring Framework’s annotations and provides a single annotation that saves us from manual configurations including XML based configurations. For example, @SpringBootApplication annotation is a combination of three annotations provided by Spring framework. They are @Configuration, @ComponentScan, and @EnableAutoConfiguration. Here @SpringBootApplication annotation is specific to SpringBoot.
3) Embedded Servers
Spring Boot comes with embedded HTTP servers like Tomcat, Jetty and Undertow. These servers come in the form of jars. However, Tomcat is by default enabled by Spring Boot. We can enable Jetty and Undertow easily if required. In short, we can easily enable or disable these servers based on our requirements.
4) Easier to connect with Databases
It allows connecting easily with databases like Oracle, PostgreSQL, MySQL, MongoDB, Redis etc. Moreover, it also allows easy integration with queue messaging services like ActiveMQ, Rabbit MQ, ElasticSearch and many more.
5) Supports development of Microservices
It works well with microservices. The Spring Boot artifacts can be deployed directly into Docker containers.
6) Default setup for Testing
Spring Boot facilitates the creation and testing of Java-based applications by providing a default setup for unit and integration tests.
7) Run Application as a jar file
It provisions to run the jars independently using the command java -jar. Hence, even we can run a web MVC application using the command java -jar.
8) Spring Boot Profile to easy switch environment
It’s profile concept simplifies the process to run our application in different environments by just changing profile name & server details.
9) Spring Boot Actuator for Application Monitoring
Apart from the application development, Spring Boot offers us the capability to inspect the internal working of the application through Spring Boot Actuator. Spring Boot Actuator provides endpoints for managing and monitoring of our Spring Boot application.
10) Increases Productivity and minimizes Development time
Needless to say, Spring Boot helps us in increasing productivity and saving development time.
What are the disadvantages of Spring Boot ?
1) One of the disadvantage that many developers face at the time of development is that it includes many additional dependencies which are not required. It increases the deployment file size. However, if we compare with the list of advantages, this disadvantage becomes negligible. If the size criteria are our priority, then this becomes really a big disadvantage.
2) Another disadvantage is that there is a challenge to update code of legacy Spring based projects. However, we can overcome this problem by using Spring Boot CLI (Command Line Interface). It will help us to convert legacy code.
How many ways are there to create a Spring Boot Application?
In order to create a Spring Boot Application, we have multiple ways.
1) Using Spring Boot CLI Tool
2) Using Spring STS IDE
3) Using Spring Initializr Website
Out of them, STS (Spring Tool Suite) IDE is the most commonly used way of developing a SpringBoot project in the industry. It has various features and is the most user friendly. Even it also saves our development time. If you are new to STS, you can visit the article on ‘How to create a SpringBoot Project using STS ?‘
What are the Starters in Spring Boot ?
In Spring Boot, Starters are the ready made small projects that we can include in our application. Officially they are called dependency descriptors. The starters contain a lot of the dependencies that you need to get a project up and running quickly and with a consistent, supported set of managed transitive dependencies. For example, if you want to get started with Spring Web Application, include the spring-boot-starter-web dependency in your project. However, if you are using STS as an IDE, you need to just search for ‘Web’ and select ‘Spring Web’. The STS will automatically add the ‘spring-boot-starter-web’ dependency in your pom.xml.
All official starters follow a similar naming pattern; spring-boot-starter-*, where * is a particular type of application. This naming structure is intended to help when you need to find a starter. As aforementioned, the Maven integration with many IDEs like STS lets you search dependencies by name.
List of Common Starters
Below is the list of some application starters provided by SpringBoot under the org.springframework.boot group:
|spring-boot-starter||Core starter, including auto-configuration support, logging and YAML|
|spring-boot-starter-activemq||Starter for JMS messaging using Apache ActiveMQ|
|spring-boot-starter-aop||Starter for aspect-oriented programming with Spring AOP and AspectJ|
|spring-boot-starter-data-jpa||for using Spring Data JPA with Hibernate|
|spring-boot-starter-batch||for using Spring Batch|
|spring-boot-starter-cache||Starter for using Spring Framework’s caching support|
|spring-boot-starter-data-jdbc||Starter for using Spring Data JDBC|
|spring-boot-starter-data-ldap||for using Spring Data LDAP|
|spring-boot-starter-data-mongodb||for using MongoDB document-oriented database and Spring Data MongoDB|
|spring-boot-starter-validation||Starter for using Java Bean Validation with Hibernate Validator|
|spring-boot-starter-data-elasticsearch||Starter for using Elasticsearch search and analytics engine and Spring Data Elasticsearch|
|spring-boot-starter-data-rest||for exposing Spring Data repositories over REST using Spring Data REST|
|spring-boot-starter-freemarker||for building MVC web applications using FreeMarker views|
|spring-boot-starter-integration||Starter for using Spring Integration|
|spring-boot-starter-jersey||Starter for building RESTful web applications using JAX-RS and Jersey. An alternative to starter-web|
|spring-boot-starter-json||for reading and writing json|
|spring-boot-starter-mail||for using Java Mail and Spring Framework’s email sending support|
|spring-boot-starter-security||Starter for using Spring Security|
|spring-boot-starter-test||Starter for testing SpringBoot applications with libraries including JUnit Jupiter, Hamcrest and Mockito|
|spring-boot-starter-web||for building web, including RESTful, applications using Spring MVC. Uses Tomcat as the default embedded container|
|spring-boot-starter-webflux||for building WebFlux applications using Spring Framework’s Reactive Web support|
|spring-boot-starter-thymeleaf||Starter for building MVC web applications using Thymeleaf views|
Starters to get Production Ready features
Spring Boot incorporates a number of additional features to help you monitor and manage your application in production. The actuator module offers all of SpringBoot’s production-ready features. The recommended way to enable the features is to add a dependency on the spring-boot-starter-actuator ‘Starter’.
Starter for using Actuator which provides production ready features to help you monitor and manage your application
Starters for Swapping or excluding technical features
Finally, It also includes the following starters that can be used if you want to exclude or swap specific technical facets.
Starter for using Jetty as the embedded servlet container. An alternative to starter-tomcat
for using Undertow as the embedded servlet container. An alternative to starter-tomcat
for logging using Logback. Default logging starter
Starter for using Reactor Netty as the embedded reactive HTTP server.
Starter for using Tomcat as the embedded servlet container. Default servlet container starter used by starter-web
Starter for using Log4j2 for logging. An alternative to starter-logging
Moreover, the complete List of starters is on official spring.io website.
After going through all the theoretical & some example part of ‘What is Spring Boot ?’, finally, we should be able to answer What is Spring Boot All About?, and also What does it do at all. Therefore, we expect from you to further utilize your knowledge and implement them in your project accordingly. Furthermore, If there is any update in future, we will also update the article accordingly. Moreover, Feel free to provide your comments in comments section below.