🏠Spring BootSpring Boot Interview Questions 2021

Spring Boot Interview Questions 2021

Let’s go through some of the important Spring Boot interview questions for beginners. We gathered these questions from some of the top MNCs across the globe.

spring boot interview questions
Spring Boot Interview questions Photo by Sora Shimazaki from Pexels

What is Spring Boot?

Spring Boot is an opinionated view of the Spring ecosystem and third-party libraries to kickstart an application development with ease. Spring Boot makes this possible through starters and their auto-configurations.

What is the difference between spring framework and Spring Boot?

Spring Framework or Spring ecosystem is a set of java libraries that help build web applications using Inversion of Control (Dependency Injection). To Implement using Spring Framework, The developers will have a write a considerable amount of configuration and boilerplate code.

On the other hand, Spring Boot is an opinionated view of Spring Framework. Thus, the developers can build applications with minimal or no configuration so that the developers can concentrate more on the business logic.

Why should we use Spring Boot?

Spring Boot establishes dogmatic defaults with options for you to extend these defaults. This way, the developers don’t have to make a lot of architectural decisions. If their solutions don’t fit the defaults, they can always provide a custom implementation.

Secondly, Spring boot avoids a lot of developer nightmares like XML configuration files, dependency management, and build packaging, etc.

Spring Boot provides embedded tomcat, out-of-the-box JPA support, auto configurations for security, etc. Thus, starting a new project is as easy as it can be. Take a look at how easy it is to write a RESTful JPA application.

What are Spring Boot starters?

Spring Boot starters are a special type of dependencies that comes with a set of auto-configuration classes and sometimes third-party dependencies. For example, Spring Boot Starter Web takes care of Spring MVC-related configurations and the dependencies for the embedded tomcat. Given that the third-party dependencies are hand-picked by the Spring developers, We do not have to manage the dependencies ourselves.

Also, note that The official spring boot starters will start with the spring-boot-starter-* pattern. This also means that there are third-party starters too. Learn more about Spring Boot Starters.

What is an auto-configuration?

Auto configurations are a set of pre-made solutions for Spring Ecosystem by the Spring Developers. These auto-configuration modules will be part of Spring Boot starters and are activated once included in the project. In addition, These auto configurations help deal with most of the boilerplate code like Hibernate files, web.xml, etc.

How to create a Spring Boot Application?

There are many ways to create a Spring Boot application. Above all, The common way to do this is through Spring Initializer. However, most of the IDEs provide ways to create spring boot applications through their new project options.

What are health check indicators?

In general, Application health checks are URLs that provide the current operational status of an application. In Spring Boot, health checks are baked in by default. Usually, each spring boot starter will come with its own auto configurations to provide a health check monitor. Subsequently, The actuator module will pick these signals and provide us with an URL to see the results. You can learn more about health indicators at Spring Boot Health Endpoint. You can also write your own implementation to provide custom health check indicators.

What is DevTools in Spring Boot?

The Spring Boot DevTools module gives rich experience to the developers while building a Spring Boot application. The DevTools does this by providing auto-completion, automatic restart on a code change, and quick reload of application contexts, etc.

Devtools is a compile-time dependency thus the production builds will exclude them. When devtools are enabled, Spring Boot won’t cache template files. With the help of LiveReload plugins, the browsers can make full use of automatic reloads.

How to configure a Spring Boot Application?

Every Spring boot project comes with an application.properties file in its src/main/resources/ directory by default. We can use this file to provide configurations that are understandable by the starters or our application code.

You can also provide an application.yaml instead of the properties file. In some cases, you can pass the configurations as JVM arguments or program arguments.

Which servers does Spring Boot Support?

Spring boot provides full support to Tomcat, undertow, and jetty as its embedded application servers. By default, Tomcat is the out-of-the-box embedded server. However, you can switch to undertow or jetty, by excluding tomcat dependencies and including one of the other two.

For instance, if you want to use jetty as the embedded solution, you need to exclude spring-boot-starter-tomcat from the maven project and include spring-boot-starter-jetty as a dependency.

Related

Similar Posts

Leave a Reply

Your email address will not be published. Required fields are marked *