Spring Boot backend interviews
Preparing for a backend role built on Spring Boot. From the container to a request, then transactions, JPA, security, testing, messaging and resilience, in the order a service is built.
16 questions, about 1 and a half hours of reading
Start with the first question- What does inversion of control mean in Spring, and how is it different from a class creating its own dependencies or using a service locator?
- Why is constructor injection recommended over field injection in Spring? Is @Autowired needed on the constructor?
- List the steps Spring goes through to create a singleton bean, from instantiation to ready for use, and the steps at shutdown.
- What does singleton scope mean in Spring, and how is it different from the singleton design pattern?
- Explain how @SpringBootApplication leads to a DataSource bean being created when you add spring-boot-starter-jdbc and a database driver.
- When would you use @Value and when @ConfigurationProperties? List the differences.
- Describe the full life of an HTTP request in a Spring Boot MVC application, from the socket to the response.
- What does @RestController add compared to @Controller, and what do @GetMapping and @RequestMapping do?
- What is @RestControllerAdvice, and how do you limit it to certain controllers?
- How does Spring apply features such as @Transactional, @Async and @Cacheable to your beans?
- How does @Transactional work in Spring? Describe what happens from the moment a caller invokes an annotated method on a bean.
- What is the persistence context (first-level cache), and what guarantee does it provide within a transaction?
- Describe the path of an HTTP request through Spring Security in a Spring Boot servlet application, from the servlet container to your controller. Name the main filters in order for an application with form login and CSRF enabled.
- What does @WebMvcTest load and not load, and how does it differ from @DataJpaTest?
- Explain how a Kafka consumer group assigns partitions to consumers and what happens during a rebalance. A topic has 6 partitions and a Spring @KafkaListener has concurrency = 3 in each of 4 pods. How many consumers actually receive data?
- Describe the states of a Resilience4j circuit breaker and what moves it between them. What do failureRateThreshold, slidingWindowSize, minimumNumberOfCalls and waitDurationInOpenState control?
Mark a question as done on its page and it is ticked here. Kept in this browser only.