Important Spring Boot Key Features

In this quick article, we will discuss one important Spring Boot interview question - Explain the Spring boot's important Spring boot key features.

Important Spring Boot Key Features

Let me a list of a few key features of the Spring boot and we will discuss each key feature briefly.
  1. Spring Boot starters
  2. Spring Boot autoconfiguration
  3. Elegant configuration management
  4. Spring Boot actuator
  5. Easy-to-use embedded servlet container support

1. Spring Boot Starters

Spring Boot offers many starter modules to get started quickly with many of the commonly used technologies, like SpringMVC, JPA, MongoDB, Spring Batch, SpringSecurity, Solr, ElasticSearch, etc. These starters are pre-configured with the most commonly used library dependencies so you don’t have to search for the compatible library versions and configure them manually.
For example, the spring-boot-starter-data-jpa starter module includes all the dependencies required to use Spring Data JPA, along with Hibernate library dependencies, as Hibernate is the most commonly used JPA implementation.

One more example, when we add the spring-boot-starter-web dependency, it will by default pull all the commonly used libraries while developing Spring MVC applications, such as spring-webmvcjackson-jsonvalidation-api, and tomcat.
Not only does the spring-boot-starter-web add all these libraries but it also configures the commonly registered beans like DispatcherServletResourceHandlersMessageSource, etc. with sensible defaults.

2. Spring Boot Autoconfiguration

Spring Boot addresses the problem that Spring applications need complex configuration by eliminating the need to manually set up the boilerplate configuration.
Spring Boot takes an opinionated view of the application and configures various components automatically, by registering beans based on various criteria. The criteria can be:
  • Availability of a particular class in a classpath
  • Presence or absence of a Spring bean
  • Presence of a system property
  • An absence of a configuration file
For example, if you have the spring-webmvc dependency in your classpath, Spring Boot assumes you are trying to build a SpringMVC-based web application and automatically tries to register DispatcherServlet if it is not already registered. 
If you have any embedded database drivers in the classpath, such as H2 or HSQL, and if you haven’t configured a DataSource bean explicitly, then Spring Boot will automatically register a DataSource bean using in-memory database settings.
You will learn more about the autoconfiguration on What is Spring Boot Auto Configuration?

3. Elegant Configuration Management

Spring supports externalizing configurable properties using the @PropertySource configuration. Spring Boot takes it even further by using the sensible defaults and powerful type-safe property binding to bean properties. Spring Boot supports having separate configuration files for different profiles without requiring many configurations.

4. Spring Boot Actuator

Being able to get the various details of an application running in production is crucial to many applications. The Spring Boot actuator provides a wide variety of such production-ready features without requiring developers to write much code. Some of the Spring actuator features are:
  • Can view the application bean configuration details
  • Can view the application URL mappings, environment details, and configuration parameter values
  • Can view the registered health check metrics
Read more about Spring Boot Actuator on Spring Boot Actuator

5. Easy-to-Use Embedded Servlet Container Support

Traditionally, while building web applications, you need to create WAR type modules and then deploy them on external servers like TomcatWildFly, etc. But by using Spring Boot, you can create a JAR type module and embed the servlet container in the application very easily so that the application will be a self-contained deployment unit. 
Also, during development, you can easily run the Spring Boot JAR type module as a Java application from the IDE or from the command-line using a build tool like Maven or Gradle.

References



Comments