DEV Community

Nishchya Verma
Nishchya Verma

Posted on

Top 20 Spring-boot questions for interview

Here is a list of top 20 Spring Boot questions. These cover core Spring Boot, best practices, integrations, performance, and real-world architecture.

I've divided them under sub-headings and not covered the answers as it will be better for you to find answers to these questions yourself as it promote learning. Use ChatGpt or some other ai or just google search like old times to deepen your understanding. Feel free to add more questions in the comments below.

Core Spring Boot & Configuration

Q1. What is the difference between @Component, @Service, @Repository, and @Controller? When should each be used?
Q2. How does Spring Boot auto-configuration work? Can you override auto-configured beans?
Q3. How would you organize a large Spring Boot project with multiple modules?

REST API Design & Best Practices

Q4. How do you design a versioned REST API in Spring Boot?
Q5. How do you handle global exceptions in Spring Boot REST APIs?
Q6. What is the purpose of @RestControllerAdvice and how does it differ from @ControllerAdvice?

Spring Boot + Data Layer

Q7. How do you optimize performance when using Spring Data JPA with large datasets? (pagination, projections, batch processing)
Q8. What are common causes of N+1 query problems in JPA and how do you fix them?
Q9. How do you handle transactions across multiple services or databases in Spring Boot?

Security and Authentication

Q10. What is the difference between session-based and token-based authentication (JWT)? How would you implement JWT in Spring Boot?
Q11. How would you implement role-based access control (RBAC) using Spring Security?

Spring Boot Advanced Concepts

Q12. What are some common memory issues or performance bottlenecks you've faced in Spring Boot apps and how did you solve them?
Q13. What is the role of @Transactional? What happens if it's used on private methods or internal calls within the same bean?
Q14. How do you use async processing in Spring Boot? What are potential pitfalls (e.g. context loss, exception handling)?

Spring Boot + Messaging/Kafka

Q15. How do you integrate Kafka with Spring Boot? What are best practices for idempotent consumers and error handling?
Q16. What is the difference between @KafkaListener and KafkaTemplate and when do you use each?

Testing & Observability

Q17. How do you write integration tests for Spring Boot applications with an in-memory database and mock services (e.g., Testcontainers, @MockBean)?
Q18. How do you implement centralized logging and tracing (using Sleuth, Zipkin, ELK, or OpenTelemetry) in a microservice architecture?

DevOps and Deployment Readiness

Q19. How do you externalize configuration in Spring Boot? What are your strategies for different environments (Dev, QA, Prod)?
Q20. How do you ensure your Spring Boot service is production-ready (health checks, metrics, graceful shutdown, retry policies)?

Top comments (0)