Some Frequently asked question in Spring boot
Here are 28 Spring Boot–focused interview questions, one for each of your listed topics:
-
@Qualifier
How does the@Qualifier
annotation work in Spring, and when would you use it to resolve bean conflicts? -
@Profile
Explain the purpose of the@Profile
annotation in Spring Boot and give an example of how to enable a bean only under a specific profile. -
Controller vs. @RestController
What’s the difference between@Controller
and@RestController
in Spring Boot, and when should you use each? -
@SuppressWarnings
What is the use of the@SuppressWarnings
annotation in Java, and how might you apply it in a Spring Boot project? -
Default Values in application.properties
How can you specify default values for configuration properties inapplication.properties
(or YAML) and override them at runtime? -
Bean Scopes
What are the different bean scopes available in Spring (e.g., singleton, prototype), and how do they affect bean instantiation and lifecycle? -
Spring vs. Spring MVC vs. Spring Boot
Compare the core Spring Framework, Spring MVC, and Spring Boot in terms of setup, configuration, and typical use cases. -
Custom Exception
How do you define and throw a custom exception in Spring Boot, and how would you return a meaningful error response to the client? -
Debugger
What tools and techniques do you use to debug a Spring Boot application locally or in a remote environment? -
@ControllerAdvice (Global Exception Handling)
How does@ControllerAdvice
work in Spring Boot, and how can you use it to implement global exception handling? -
ExceptionHandler per Controller
How do you handle exceptions differently in separate controller classes using@ExceptionHandler
? -
final Initialization
When and why would you mark a field or method asfinal
in your Spring Boot components? -
Interface Variable Declaration
Can you declare variables in a Java interface? How does that feature play into designing Spring Boot applications? -
Benefits of Spring Boot over Spring
What are the key advantages of Spring Boot compared to the traditional Spring Framework? -
Spring Batch
What is Spring Batch, and in what scenarios would you choose it over plain JDBC or other ETL tools? -
YAML in Spring Boot
How do you structure and load configuration using a YAML (.yml
) file in Spring Boot? -
Interceptor in Spring Boot
What is a Spring Boot interceptor, how do you register one, and how does it differ from a filter? -
Actuator
What is Spring Boot Actuator, and which built-in endpoints would you use to monitor application health and metrics? -
@Inject vs. @Autowired
How does@Inject
(JSR-330) compare to Spring’s@Autowired
annotation in dependency injection? -
Editing Properties at Runtime
Is it possible to modifyapplication.properties
values while a Spring Boot app is running? If so, how? -
Spring Starter
What is a “starter” dependency in Spring Boot, and how do starters simplify building applications? -
Components of Spring
What are the primary modules (e.g., Core, AOP, Data) that Spring Boot builds on, and what role does each play? -
CrudRepository vs. JpaRepository
What’s the difference betweenCrudRepository
andJpaRepository
in Spring Data JPA, and when would you choose one over the other? -
Changing the Server
How do you change the embedded server’s port, context path, or servlet container (e.g., from Tomcat to Jetty) in Spring Boot? -
Yammer Metrics in Actuator
What role did the Yammer metrics library play in earlier versions of Spring Boot Actuator, and how has metrics support evolved? -
RestTemplate
How doesRestTemplate
work in Spring Boot for making HTTP calls, and what newer alternative does Spring recommend? -
Validation
How do you implement request data validation in Spring Boot using Hibernate Validator (JSR-380) annotations? -
Transaction Rollback
How would you configure a Spring Boot service method so that database changes roll back automatically when an exception occurs?
Comments
Post a Comment