Spring Boot Interview Questions and Answers
Spring Boot interviews go beyond annotations. Interviewers want to know how auto-configuration decides which beans to create, how dependency injection and bean scopes behave, what a transaction boundary really covers, and how you would debug a slow or failing endpoint in production.
The questions below are the Spring-related ones from our Java collection. Read the answer, then try to explain the mechanism in your own words: that is the difference between knowing the annotation and understanding the framework.
Questions
- What is Inversion of Control (IoC) in the Spring Framework?
- What is the Spring IoC container and the difference between BeanFactory and ApplicationContext?
- How does Spring resolve which bean to inject when multiple candidates exist?
- Explain the Spring Bean Lifecycle.
- What are the different Spring Bean scopes?
- What are request and session scopes in Spring?
- What is Spring Boot and how does it differ from Spring?
- Explain `@SpringBootApplication`.
- How does Spring Boot Auto-Configuration work?
- What is the role of `spring.factories` / `AutoConfiguration.imports`?
- What are Spring Boot Starters?
- How do you externalize configuration in Spring Boot?
- How does Spring Boot handle profiles?
- What are the embedded servers in Spring Boot?
- How do you handle exceptions in Spring REST with `@ExceptionHandler`?
- How do you validate request bodies in Spring?
- What is Spring AOP and what problem does it solve?
- What is the difference between Spring AOP and AspectJ?
- What is `@Transactional` and how does Spring manage transactions?
- What is a circular dependency and how does Spring handle it?
- How do you test a Spring Boot application?
- What is the difference between `@SpringBootTest` and test slices?
- What is Spring Cloud Config Server?
- What is Spring Cloud and how does it relate to microservices?
- How do you secure microservices with Spring Security / OAuth2?
- What is Spring Boot DevTools?
- How do you package and run a Spring Boot application?
- What are the 12-factor app principles relevant to Spring Boot microservices?
- Spring Security test support
- What is integration testing with Spring Boot?
- How do you test Spring Security-protected endpoints?
- What is `@SpringBootTest(webEnvironment = RANDOM_PORT)`?
- What is the difference between unit and integration tests in Spring?
- Your Spring Boot API suddenly becomes 5× slower in production. How would you find the root cause?
- Your Spring Boot application slowly consumes more memory and eventually crashes. How would you investigate the memory leak?
- Multiple instances of your Spring Boot application are processing the same event. How would you prevent duplicate processing?
- 4. How Do You Handle Global Exceptions in Spring Boot?
- 5. How Do You Implement Pagination and Validation in Spring Boot?
- How Do You Update application.properties Without Redeploying a Spring Boot Service?
- @Value vs. @ConfigurationProperties in Spring Boot
Related
Frequently asked questions
What is Spring Boot auto-configuration?
It creates beans automatically based on what is on the classpath and on your properties, using conditional configuration, so a starter dependency is usually enough to get a working component.
What do interviewers ask about Spring transactions?
Where the transaction boundary is, why a self-invocation inside the same class skips the proxy, propagation and isolation levels, and how rollback works for checked and unchecked exceptions.
How do I prepare for Spring Boot questions quickly?
Build or review one small REST service end to end (controller, service, repository, a transaction, a test), then read the questions here and explain each mechanism aloud.