Spring Boot Interview Questions
Part of the Java Roadmap
In short
For Java backend roles, Spring Boot questions decide the second round. Interviewers want to see that you know what the annotations actually do, not just that you've typed them.
Common questions cover dependency injection and bean scopes, auto-configuration, @Component vs @Service vs @Repository, @Transactional, profiles, exception handling, JPA relationships and the N+1 problem.

Think of it like this
The stand-in actor
In a film shoot, a body double sometimes steps in for the star. The director talks to the double, who adds the stunt and then lets the star deliver the line. Spring does this with proxies: when you call a @Transactional method from another bean, you're really calling a proxy that opens a transaction, then calls your code. Call it from inside the same class and you skip the double entirely.
Watch it happen
Why @Transactional sometimes does nothing
placeOrder()
1/4The controller holds a reference to a Spring proxy, not the real OrderService.
The big ideas
What you need to know
Auto-configuration
Boot configures beans based on classpath and properties, using @ConditionalOnClass and @ConditionalOnMissingBean. Your own beans win.
@Component vs @Service vs @Repository
All register beans. @Repository also translates database exceptions into Spring's DataAccessException.
Bean scopes
singleton (default), prototype, and web scopes like request and session.
N+1 and fetch types
Know LAZY vs EAGER, why N+1 happens and how JOIN FETCH or @EntityGraph fixes it.
See it in code
Walk through the code
1import org.springframework.stereotype.Service;2import org.springframework.transaction.annotation.Propagation;3import org.springframework.transaction.annotation.Transactional;4 5@Service6public class OrderService {7 private final AuditService audit;8 private final OrderRepository orders;9 10 public OrderService(AuditService audit, OrderRepository orders) {11 this.audit = audit;12 this.orders = orders;13 }14 15 @Transactional16 public void placeOrder(Order order) {17 orders.save(order);18 audit.log("Order placed: " + order.getId()); // goes through AuditService's proxy19 if (order.getTotal().signum() <= 0) {20 throw new IllegalArgumentException("Empty order"); // rolls back the save21 }22 }23}24 25@Service26class AuditService {27 @Transactional(propagation = Propagation.REQUIRES_NEW)28 public void log(String message) {29 // saved in its own transaction, kept even if placeOrder rolls back30 }31}1/4The whole method runs in one transaction opened by the proxy.
Classic follow-up: by default @Transactional rolls back only on unchecked exceptions. Use rollbackFor = Exception.class for checked ones.
Save yourself the pain
Common mistakes
Oops
Saying @Transactional works on private methods or self-calls.
Do this instead
Proxies only intercept public calls from outside the bean. Self-invocation skips the transaction.
Oops
Saying all exceptions trigger rollback.
Do this instead
Only unchecked exceptions and Errors by default. Checked exceptions commit unless you set rollbackFor.
Oops
Answering 'What is Spring Boot?' with 'a framework for Java'.
Do this instead
Say it's opinionated Spring with auto-configuration, starters, an embedded server and production features like Actuator.
Your mission
Fifteen-question mock
Quick check
A @Transactional method throws a checked IOException. What happens by default?
Go deeper
- 1Prepare a short answer with an example for each common question.
- 2Explain the life of a request from DispatcherServlet to the database and back.
- 3Be ready to walk through the layers of your own Spring Boot project.
More topics at this stop
Stuck on this topic? Ask an Insider
Get 1:1 guidance from people who've walked this exact path — on the InsideEdge app.