0% found this document useful (0 votes)
404 views

Spring Boot Interview Questions

This document discusses Spring Boot interview questions and answers. It covers topics like what is Spring Boot, why use Spring Boot over Spring, how Spring Boot works, common annotations in Spring Boot, starters in Spring Boot, and other concepts like Thymeleaf template engine.

Uploaded by

Akanksha Ojha
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
404 views

Spring Boot Interview Questions

This document discusses Spring Boot interview questions and answers. It covers topics like what is Spring Boot, why use Spring Boot over Spring, how Spring Boot works, common annotations in Spring Boot, starters in Spring Boot, and other concepts like Thymeleaf template engine.

Uploaded by

Akanksha Ojha
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 13

Spring Boot Interview Questions

Part-1

Learn Code With Durgesh


Q1) What is Spring Boot

1. Spring Boot is a Java framework that makes it easier to create and run
Java applications.
2. It simplifies the configuration and setup process, allowing developers to
focus more on writing code for their applications.
3. Spring Boot, a module of the Spring framework, facilitates Rapid
Application Development (RAD) capabilities.
4. Spring Boot solve many developers problem
a. Configurations
b. Dependency Management
c. Embedded Server
d. And many more.

Learn Code With Durgesh


Q2) Why Spring Boot over Spring?

1. Spring Boot provide many advantages over normal spring framework


a. Easy to use- Remove boilerplate codes
b. Production Ready applications- Metrix, Health Check and many
features are designed for production ready application.
c. Rapid Development- Opinionated approach and auto-configuration
enable developers to quickly develop apps
d. Provide Dependency Management- No need to manager separate
dependencies manually.
e. Autoconfiguration - Spring Boot AutoConfigure things by default.
f. Embedded Server : provide tomat server by default.

Learn Code With Durgesh


Q3) Working of Spring Boot

1. Spring Boot starts by scanning the starter dependencies in pom.xml


Then download and auto-configure the module as you included in pom.xml
2. For example we have to create web application then we have to put
spring-boot-starter-web dependency in pom.xml.
When we start the project spring boot downloads all the dependency
required for web and configure the things like spring mvc.

Learn Code With Durgesh


Q4) How Spring Boot Starts?

1. Starts by calling main() method of you main class.


2. The run() method of SpringApplicaiton is called. This method starts the
application by creating an application context and initializing it.
3. Once the application context is initialized, the run() method starts the
application’s embedded web server.

Learn Code With Durgesh


Q5) Top Spring Boot Annotations

■ @SpringBootApplication: It combines three annotations:


@Configuration,@EnableAutoConfiguration, and @ComponentScan. It is
typically placed on the main class of the application.
■ @Component: It is used to mark a class as a Spring bean that will be
managed by the Spring container.
■ @Autowired: This annotation is used to automatically inject dependencies
into a Spring-managed bean.
■ @Service: This annotation is used to indicate that a class represents a
service component in the application. It is typically used to annotate
classes that contain business logic.
■ @RestController:Mark class as REST Controller. It is a specialized version
of the @Controller annotation that includes the @ResponseBody
annotation by default.

Learn Code With Durgesh


■ @RequestMapping: used to map specific url to method.Used on class as
well as method level.
■ @Repository: mark class as DAO. mostly used on class that has database
persistent logic.

Learn Code With Durgesh


Q6) What are the Spring Boot Starters

■ Starters are a collection of pre-configured dependencies that make it


easier to develop particular kinds of applications.
■ These starters include all of the dependencies, version control, and
configuration needed to make certain features of a Spring Boot application
functional.

Learn Code With Durgesh


Q7) What are the key dependencies of Spring
Boot?
1. spring-boot-starter-parent
2. spring-boot-maven-plugin
3. spring-boot-starter-test
4. spring-boot-starter-security
5. spring-boot-starter-actuator
6. Spring-boot-starter-web
7. ……

Learn Code With Durgesh


Q8) what is Spring-Boot-Starter-Parent?

1. Spring Boot Starter Parent is a starter project that provides the default
configuration for spring-based applications.
a. The dependency management feature manages the versions of
common dependencies.
b. Provide the default compiler level as Java 1.8 and UTF-8 source
encoding.
c. Provides a default configuration for Maven plugins such as
maven-surefire-plugin, maven-jar-plugin, and maven-failsafe-plugin.
d. Executes a repackage goal with a repackage execution id.
e. Resource filtering and configuring profile-specific files.

Learn Code With Durgesh


Q9) Can we use Only Spring Boot Dependency
feature and configure maven plugin manually?

1. YES
2. We don’t inherit from the spring-boot-starter-parent pom.
3. Include the spring-boot-dependencies dependency inside the
dependencyMangement section as an import scope.

Learn Code With Durgesh


Q10) What is Spring Boot CLI and what are its
benefits?

Command line tool to create,run and manage spring boot Applications

>>spring
>>spring help init
>>spring version
>>spring init --dependencies=web,data-jpa my-project
>> spring init --list

Learn Code With Durgesh


Q11) What is thymeleaf?

Java-based server-side templating engine used in Java web applications to


render dynamic web pages.

Request

client Server
(Browser) (Spring boot)

Thymeleaf

Response Dynamic
page(html)
Learn Code With Durgesh

You might also like