0% found this document useful (0 votes)
5 views5 pages

Complete Spring Boot Interview Questions

The document provides a comprehensive list of Spring Boot interview questions and answers, covering advantages, key components, and functionalities of Spring Boot. It explains concepts such as starter dependencies, auto-configuration, annotations, and the Spring Actuator. Additionally, it addresses application setup, server configurations, and dependency management within the Spring Boot framework.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
5 views5 pages

Complete Spring Boot Interview Questions

The document provides a comprehensive list of Spring Boot interview questions and answers, covering advantages, key components, and functionalities of Spring Boot. It explains concepts such as starter dependencies, auto-configuration, annotations, and the Spring Actuator. Additionally, it addresses application setup, server configurations, and dependency management within the Spring Boot framework.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 5

Spring Boot Interview Questions and Answers

1. What are the advantages of using Spring Boot?

Spring Boot simplifies application development by providing features like auto-configuration,

embedded servers, and starter dependencies. It reduces boilerplate code, increases productivity,

and makes it easier to develop production-ready applications.

2. What are the Spring Boot key components?

Key components of Spring Boot are:

- Spring Initializer

- Auto-Configuration

- Embedded Server (like Tomcat or Jetty)

- Spring Boot CLI

- Spring Boot Actuator.

3. Why Spring Boot over Spring?

Spring Boot eliminates the need for complex configuration and reduces development time by

providing pre-configured templates, auto-configuration, and embedded servers.

4. What is the starter dependency of the Spring Boot module?

Starter dependencies are predefined dependencies that simplify project configuration. Examples

include 'spring-boot-starter-web' for web applications and 'spring-boot-starter-data-jpa' for

JPA-based applications.

5. How does Spring Boot work?

Spring Boot uses auto-configuration to detect the libraries in the classpath and configures them

automatically based on application needs.

6. What does the @SpringBootApplication annotation do internally?


It combines three annotations: @Configuration, @EnableAutoConfiguration, and

@ComponentScan, enabling auto-configuration and component scanning.

7. What is the purpose of using @ComponentScan in the class files?

It allows Spring to scan packages for annotated components (@Component, @Service, etc.) to

register them as beans.

8. How does a Spring Boot application get started?

By calling the static run() method of SpringApplication, which initializes the context and starts the

embedded server.

9. What are starter dependencies?

Starter dependencies simplify dependency management by bundling related libraries. Examples

include spring-boot-starter-web and spring-boot-starter-security.

10. What is Spring Initializer?

Spring Initializer is a web-based tool that generates a Spring Boot project with necessary

configurations and dependencies.

11. What is Spring Boot CLI and what are its benefits?

Spring Boot CLI is a command-line tool for quickly developing Spring applications. It simplifies

application development by using Groovy scripts.

12. What are the most common Spring Boot CLI commands?

Common commands include:

- 'spring init' to create a new project

- 'spring run' to run the application

- 'spring list' to list available projects.

13. What Are the Basic Annotations that Spring Boot Offers?
Key annotations include:

- @SpringBootApplication

- @RestController

- @EnableAutoConfiguration

- @Entity

- @Configuration.

14. What is Spring Boot dependency management?

Spring Boot uses a curated list of dependencies to manage version conflicts, ensuring compatibility

between libraries.

15. Can we create a non-web application in Spring Boot?

Yes, Spring Boot supports creating non-web applications using the CommandLineRunner or

ApplicationRunner interfaces.

16. Is it possible to change the port of the embedded Tomcat server in Spring Boot?

Yes, the port can be changed in application.properties or application.yml by setting

'server.port=PORT_NUMBER'.

17. What is the default port of Tomcat in Spring Boot?

The default port is 8080.

18. Can we override or replace the Embedded Tomcat server in Spring Boot?

Yes, by excluding the Tomcat dependency and adding a Jetty or Undertow dependency.

19. Can we disable the default web server in the Spring Boot application?

Yes, set 'spring.main.web-application-type=none' in the application properties.

20. How to disable a specific auto-configuration class?

Use the @EnableAutoConfiguration(exclude={ClassName.class}) annotation.


21. Explain @RestController annotation in Spring Boot?

@RestController is a combination of @Controller and @ResponseBody, simplifying the creation of

RESTful web services.

22. What is the difference between @RestController and @Controller in Spring Boot?

@RestController returns data directly as a JSON or XML response, while @Controller is used for

building web applications with views.

23. Describe the flow of HTTPS requests through the Spring Boot application?

1. HTTPS requests reach the server.

2. Embedded Tomcat handles the SSL handshake.

3. Requests are processed by filters and dispatched to controllers.

24. What is the difference between RequestMapping and GetMapping?

@RequestMapping can handle all HTTP methods, while @GetMapping is specifically for GET

requests.

25. What is the use of Profiles in Spring Boot?

Profiles allow different configurations for different environments (e.g., dev, test, prod). They can be

set in application.properties or using the '-Dspring.profiles.active' flag.

26. What is Spring Actuator? What are its advantages?

Spring Actuator provides production-ready monitoring and management endpoints like health

checks and metrics.

27. How to enable Actuator in Spring Boot application?

Add the 'spring-boot-starter-actuator' dependency and configure desired endpoints in

application.properties.

28. What are the actuator-provided endpoints used for monitoring the Spring Boot application?
Key endpoints include:

- /actuator/health

- /actuator/metrics

- /actuator/env.

29. How to get the list of all the beans in your Spring Boot application?

Access the ApplicationContext and use the 'getBeanDefinitionNames()' method.

30. How to check the environment properties in your Spring Boot application?

Use the Environment object to fetch properties programmatically or check

application.properties/application.yml files.

31. How to enable debugging log in the Spring Boot application?

Set 'debug=true' in application.properties or enable it via logging configurations.

32. Where do we define properties in the Spring Boot application?

Properties are defined in application.properties or application.yml files.

33. What is Dependency Injection?

Dependency Injection is a design pattern where dependencies are injected into a class rather than

being created within the class.

34. What is an IOC container?

The IOC (Inversion of Control) container manages the lifecycle and dependencies of beans in a

Spring application.

You might also like