Spring Boot Interview Questions

Java Spring Boot Interview Questions

  • Monika Jacob
  • 10th Nov, 2022

About Spring Boot

Spring Boot always allows easy to the setup of standalone Spring-based applications. It's ideal for pulling up new microservices and easy to organize. Spring Boot is just a way of fast starting new applications using the Spring Framework. It is not a replacement or alternative. It also makes it easier to dive into the spring world as it automates a great deal of the tiresome manual configuration of traditional spring. The spring framework proved to be slow, cumbersome, and time-consuming for developers to set up any basic project that essential Spring MVC as it provided the smallest amount of functionality. Spring Boot is an extension of the popular spring framework that was launched to eliminate the boilerplate configurations needed for building spring applications.

Spring Boot Interview Questions

1) What is Spring Boot?

Spring Boot is an open source Java-based framework used to create a micro Services. It is developed by Pivotal Team and is used to build stand-alone and production ready spring applications.

2) List some advantages of using Spring Boot?

Major advantages of using Spring Boot are

  • Simplified & version conflict-free dependency management through the starter POMs.
  • We can quickly set up and run standalone, web applications and microservices at very little time.
  • You can just assemble the jar artifact which comes with an embedded Tomcat, Jetty or Undertow application server and you are ready to go.
  • Provides HTTP endpoints to access application internals like detailed metrics, application inner working, health status, etc.
  • No XML based configurations at all. Very much simplified properties. The beans are initialized, configured and wired automatically.
  • The Spring Initializer provides a project generator to make you productive with a certain technology stack from the beginning.

3) What is bootstrapping in Spring Boot?

Bootstrapping is a process of initializing an application. Bootstrapping in spring boot application is done using Spring Initializer.

4) List minimum requirements for Spring boot System?

System Requirements to work with Spring boot 1.5.6 are

  • Java 1.6 or above
  • Maven 3.2+ or Gradle 2.9+ for building an app
  • Any servlet that is 3.0+ compatible container. You can use Tomcat 7+ or Jetty 8
  • Spring framework 4.3.10 or above

5) What is Spring Boot Actuator?

Spring Boot Actuator is a sub-project of the Spring Boot Framework. It includes a number of additional features that help us to monitor and manage the Spring Boot application. Spring Boot Actuator is mainly used to monitor endpoints, Metrics, and doing audits.

6) What is Thymeleaf in Spring Boot?

Thymeleaf is an template engine for XML/XHTML/HTML5 and Java library. It provides elegant, clean templates tag and can easily be integrated with Spring applications.

You can use Thymeleaf in the Spring Boot project by adding in the configuration of your pom.xml file.

7) What are Spring Boot Starter Projects?

Spring Boot Starters are a set of dependency descriptors that are used to build Spring Boot-based Java applications rapidly and easily. Spring Boot provides many inbuilt Starters some of them are spring-boot-starter-thymeleaf, spring-boot-starter-artemis, spring-boot-starter-web, spring-boot-starter-activemq, spring-boot-starter-validation, etc.

8) What is auto configuration in Spring Boot?

Autoconfiguration is way in Spring Boot to configure a spring application automatically on the basis of dependencies that are present on the classpath. It makes development easier and faster.

You can create a custom configuration for a MySQL data source in spring boot as

public class MySQLAutoconfiguration {


9) What is Opinionated Defaults Configuration?

Opinionated Defaults Configuration is an approach used by Spring Boot to reduce Developer efforts. It provides Embedded HTTP servers like Tomcat, Jetty etc. to develop and test our web applications very easily.

10) What are esteem properties of Spring Boot?

Spring Boot gives different properties, which can be indicated in our project’s application.properties record. These properties have default values, and you can set that inside the properties record. Properties are utilized to set qualities like a server-port number, database association configuration and many more.

11) Would you be able to Control Logging with Spring Boot?

Yes, we can control logging with spring boot.

12) What do you understand by Aspect-Oriented Programming (AOP)?

Aspect-oriented programming (AOP) is a programming paradigm that aims to increase modularity by allowing the separation of cross-cutting concerns.

13) How to add custom JS code in Spring Boot?

To add custom Js code in Spring boot you have to create a JS file and put it in /src/main/resources/static directory.

You can create a JS file for sending an alert by creating a custom file named custom.js in /src/main/resources/static/js/ directory with below code

alert("I'm active");

14) What are Spring Boot Starters?

Spring Boot Starters is a set of convenient dependency descriptors that you can include in your application. Spring Boot provides a number of starters that allow us to add jars in the classpath. Spring Boot built-in starters make development easier and rapid.

15) How to include API Throttling in Spring Boot?

API Throttling is a process to control the usages of API consumption within a time. It limits the number of requests made for a resource in a unit of time.

Spring does not provide any inbuilt components for implementing API Throttling. To implement API Throttling we can use the RateLimitter class of Guava library.

16) How to serve static files in Spring Boot?

Static files in spring boot are served from the resources directory. Spring boot automatically add static web resources located within following directories

  • /META-INF/resources/
  • /resources/
  • /static/
  • /public/

You can change the default paths of static resources by adding the path in spring.resources.static-locations property of application.properties



17) What is Spring Boot CLI?

The Spring Boot CLI is a command-line tool that you can use if you want to quickly develop a Spring application. If you have a familiar Java-like syntax without so much boilerplate code it lets you run Groovy scripts.

18) How to convert an object to json in spring boot?

objectMapper.writeValueAsString() method is used to generate JSON from an object in Spring boot.


ObjectMapper objectMapper = new ObjectMapper();
Fruit fruit = new Fruit("apple", "banana","guava");
String fruitAsJson = objectMapper.writeValueAsString(fruit);

19) How to enable HTTP/2 support in Spring Boot?

In spring boot version 2.1 and above you can enable HTTP/2 support by adding server.http2.enabled=true property to your .properties (or .yml) file.

20) Enlist few features of Spring Boot?

Few features of Spring Boot are

  • Spring CLI
  • Starter Dependency
  • Spring Initializer
  • Auto-Configuration
  • Spring Actuator
  • Logging and Security

21) How to enable auto reload or hot reloading of Spring Boot application in Intellij IDEA?

You can use auto reload or hot reloading functionality on Intellij IDEA. By adding below dependencies.


After adding the above dependencies follow the below steps.

  • Open the Settings --> Build-Execution-Deployment --> Compiler and enable the Make Project Automatically.
  • Click ctrl+shift+A and search for the registry and enable compiler.automake.allow.when.app.running
  • Restart your IDE.

22) How to change port for a Spring Boot application?

Spring boot server by default starts on port no. 8080. You can change the port for a Spring Boot application using the following ways

  • Using Property Files: This fastest and easiest way to change the port of Spring Boot. To change it simply assign desired port no to server.port property of your application.properties.
  • Programmatic Configuration: You can change the port programmatically by the setting server.port property when starting the application. Something like
    public class CustomApplication {
        public static void main(String[] args) {
            SpringApplication app = new SpringApplication(CustomApplication.class);
              .singletonMap("server.port", "8083"));
    Next, customize the server configuration by implementing the WebServerFactoryCustomizer interface:
    public class ServerPortCustomizer 
      implements WebServerFactoryCustomizer {
        public void customize(ConfigurableWebServerFactory factory) {
  • Using Command-Line Arguments: You can do it when you are packaging and running your application as a jar.


    java -jar spring-5.jar --server.port=8083

23) What are 'spring-boot-starter' jars?

In Spring Boot, jars are present in the pattern of spring-boot-starter. The jars inside spring boot do not enclose any packages. You can imply the jars to the starter POMs using automatic tools like Gradle or Maven. You can also add the jars manually to the spring boot classes via a particular classpath.

Spring Boot provides a number of starters that allow us to add jars in the classpath. Spring Boot built-in starters make development easier and rapid

24) What is HandlerMapping in Spring Boot?

HandlerMapping is an interface that defines a mapping between requests and handler objects. Using a handler mapping you can map incoming web requests to appropriate handlers. Spring boot supports handler mapping out of the box.

25) What is the easiest way to create a Spring Boot Project?

Spring initializr is the easiest way to create spring boot projects. It generates a spring boot projects easily and quickly.

26) What are key components of Spring Boot?

There are mainly four major Components of spring boot. They are

  • Spring Boot Starters.
  • Spring Boot AutoConfigurator.
  • Spring Boot CLI.
  • Spring Boot Actuator.

27) What are the Spring Boot Annotations?

Spring Boot Annotations is a form of metadata that provides data about a program. In other words, annotations are used to provide supplemental information about a program.

Some mostly used annotations in spring boot are @Bean, @Service, @Configuration, @Controller, @RequestMapping, @Repository, @Autowired, and @SpringBootApplication

3 comment(s) :

Leave A Comment :

Valid name is required.

Valid name is required.

Valid email id is required.