Top Spring Boot Interview Preparation


What does it mean by auto configuration by spring boot ?

Spring boot automatically configure bean if its corresponding library in classpath, for example if JdbcTemplate is in classpath then spring boot will configure JdbcTemplate and will create a bean that can be injected directly where its required.

What is starter dependency in spring boot ?

Starter dependency is aggregation of common dependency that are available during build for example if we are creating a web project that exposes REST API then we require spring web , spring mvc, tomcat, jackson etc.but spring boot provides web starter that has all in single dependency.If we add all dependency individually then we need to maintain all compatible version of library but using spring boot starter we get complete package that maintains all compatible version.

What is the benefit of spring boot Command line interface (CLI) ?

When we write code in spring boot CLI and use any Object or type then spring boot CLI detects starter for that type and put all related library on classpath. After library is added on classpath it uses auto configuration to create bean or injection.

What is spring boot Actuator ?

Actuator checks the internal working of application for example if our application is working with other application it can check is other application working,what are beans in spring context,what is environment variable set by application etc.

Is spring boot application server ?

No, it uses embedded container like tomcat but itself spring boot is not application server.

What is spring Initializer ?

It is an web application that creates spring boot project for developer.we can access Initializer by


How to set up basic spring initializer project ?

Spring boot project can be set up by following steps given in link.

Spring Boot Project set up

How to create REST API using spring boot ?

Spring boot REST API project can be created by following steps given in link.

Spring Boot REST Example

What is the spring Boot plugin in maven ?









What is the spring Boot plug in gradle ?

dependencies {


what are the ways to set properties for spring boot application ?

  • Command-line arguments
  • JNDI attributes from java:comp/env
  • JVM system properties
  • Operating system environment variables
  • Randomly generated values for properties prefixed with random.*
  • or application.yml file referred externally
  • or application.yml file referred internally
  • Property sources specified by @PropertySource
  • Default
Note: this list is order of precedence It means any property set higher in in list will override property set lower in in list

Which has higher precedence between and application.yml ?


How can we make template non cachable ?

Set a property in properties file

  • spring.thymeleaf.cache=false (thymeleaf)
  • spring.freemarker.cache=false (Freemarker)
  • spring.groovy.template.cache=false (Groovy templates)
  • spring.velocity.cache=false (Velocity)

How can i change port number of embedded server ?

By default tomcat starts on 8080 port.To change it other port,we need to provide a property in .properties file.

server.port = 9000

What is the default logging in spring boot?

Logback is default to log on console at INFO level.

How can we use another logging implementation instead of Logback in spring boot ?

We need to exclude Logback from dependency for example.

For maven











For gradle

configurations { all*.exclude group:'org.springframework.boot',module:'spring-boot-starter-logging'}

Add your logging implementation, for example log4j2.





How to test REST API in spring boot using mock MVC standaloneSetup method ?

Spring boot REST API can be tested using mock MVC standaloneSetup method following steps

given in link.

Spring Boot REST API Test with Mock MVC Using standaloneSetup

How to test REST API in spring boot using mock MVC webAppContextSetup method ?

Spring boot REST API can be tested using mock MVC webAppContextSetup method following steps

given in link.

Spring Boot REST API Test with Mock MVC Using webAppContextSetup

What is the significance of SpringJUnit4ClassRunner ?

It helps to load spring application context in Junit based application and enables autowiring

of beans in test class.

How @SpringApplicationConfiguration is different from @Context- Configuration ?

@SpringApplicationConfiguration loads the spring application by SpringApplication,due to which it can loads external properties, spring boot logging

What is the significance of @WebIntegrationTest ?

This annotation is used on test class to test web application.For example if we have any web application that accepts request, so to test API we create actual environment ,in which application is started in embedded server and actual HTTP request is sent to test API.

How to make actuator enable for spring boot ?

To make actuator eable for spring boot we need to include only following dependency

<dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-actuator</artifactId> </dependency>

Adding this dependency due to auto configuration ,actuator will enable.

Even after adding actuator on classpath why can we not access many endpoint in spring boot for example /bean, /metrics ?

Most endpoints are sensitive.It means they are not fully public.While some are for example /health and /info.

Most of the details exposed by endpoint is sensitive so only authorized user can access it, so we need to include spring security on class path

Add following dependency

<dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-security</artifactId> </dependency>

How can we customize an endpoint in spring boot ?

We can customize endpoint as well.Each endpoint has three properties.

  • id: id of the endpoint
  • enabled: false means it can not be accessed
  • sensitive: false means no authorize is required

For example endpoints.beans.sensitive=false endpoints.shutdown.enabled=true

What is the significance of /metrics endpoint ?

This provides snapshot of running application and give many metrics for example memory allotted, heap allocation, thread pool, garbage collector etc

What is the significance of /trace endpoint ?

This provides details of web request for example method, path, request and response header, timestamp etc.

What is the significance of /dump endpoint ?

This provides snapshot of current thread activity

How to deploy spring boot application in external tomcat ?

Spring boot application can be deployed in external tomcat using following steps

given in link.

Deployment Of Spring Boot In External Tomcat

What is the benefit of spring boot ?

It provides following benefit

  • Auto Configuration : Spring boot can itself auto configure many configuration like bean injection
  • Starter Dependency : It provides complete package of library for any functionality, by this we can be away from version mismatch
  • Command line interface : By this we can concentrate only on application code instead of trading code like import , semicolon after each line
  • Actuator : By this we can know what's going on inside running application.

What dependency should i include to reload changes without restarting server ?






Visit Others Links

Interview Questions Top Elasticsearch Interview Question
Top Kubernetes Interview Question
Top HTTP Interview Question
Top PouchDB Interview Question
Top Pivotal Cloud Foundry (pcf) Interview Question
Top Apache Camel Interview Question
Top Docker Interview Question
Top Gradle Interview Question
Top Generics Interview Questions In Java
Java 9 Interview Questions
Top Maven Interview Question
Top RabbitMQ Interview Question
Top Spring Batch Interview Question
Top Spring Boot Interview Question
Top Tika Interview Question
Top Kotlin Interview Question
Top OpenShift Interview Question
Top Polymer Interview Question
Top WebGL Interview Question
Top Continuous Integration Interview Question
Top Spring Cloud Interview Question
Top JOGL Interview Question
Top JFreeChart Interview Question
Java MultiThreading Interview Question
Top Spring ROO Interview Question
Top Seaborn Interview Question
Top TestRail Interview Question
Top LolCode Interview Question
Top Spring Transaction Management Interview Question
Top DynamoDB Interview Question
Top PySpark Interview Question
Top SaltStack Interview Question
Top Spring AOP Interview Question
© 2019