Dependency injection and beans
- Constructor versus field injection, and why constructor injection is preferred - immutability, testability, and failing fast on a missing dependency.
- Bean scopes - singleton and prototype - and the trap of injecting a prototype into a singleton.
- `@Component`, `@Service`, `@Repository` and `@Controller` - functionally similar, semantically different, with `@Repository` adding exception translation.
- How does component scanning find your beans, and what happens when a class sits outside the scanned package?
- `@Qualifier` and `@Primary` for resolving ambiguity.
The proxy question, which decides the loop
Spring wraps your beans in proxies to add behaviour. That single fact explains the most-asked gotchas:
- `@Transactional` does not apply to a self-invocation. Calling an annotated method from another method in the same class bypasses the proxy entirely. This is the single most asked Spring trap.
- The same applies to `@Cacheable` and `@Async`.
- `@Transactional` on a private method does nothing.
- JDK dynamic proxies versus CGLIB, and why the choice depends on whether an interface exists.
Auto-configuration and transactions
- What does `@SpringBootApplication` combine, and how does auto-configuration decide what to apply?
- How do you override or exclude an auto-configuration you do not want?
- Transaction propagation - `REQUIRED` versus `REQUIRES_NEW`, and when the difference matters.
- What happens to a transaction when a checked exception is thrown? By default it does not roll back, which surprises people.
- Isolation levels, and the anomalies each prevents.
Data and testing
JPA questions centre on the N+1 problem - what causes it, how you detect it, and fetch strategies to fix it - plus lazy loading outside a transaction. Testing questions cover `@SpringBootTest` versus slice tests such as `@WebMvcTest`, and why loading the whole context for every test is slow. The database half overlaps with SQL interview questions.
How deep it goes by level
- Junior: the fundamentals above, explained clearly. Nobody expects production scars yet, and honesty about what you have not done reads better than bluffing.
- Mid-level: the same ground, plus a service you have run. Expect follow-ups asking why you made a particular choice rather than whether you know the syntax.
- Senior: a transaction or N+1 problem you diagnosed under load. At this level the language questions get shorter and the judgement questions get longer.
Whatever the level, the reliable way to prepare is to say your answers out loud rather than reading them. Most of what candidates lose in a Spring Boot interview is lost in the gap between knowing something and explaining it under observation - the method is in how to use AI for interview prep.
Where CoPilot Interview fits
Disclosure: we build an interview assistant, so treat this as a disclosed pitch. CoPilot Interview is a native Windows and macOS app that puts suggested answers on your own screen in about two seconds, across coding, system design and behavioral rounds, with a permanent free tier that needs no credit card.
Frequently asked questions
What are the most common Spring Boot interview questions?
Constructor versus field injection, bean scopes, how auto-configuration works, transaction propagation levels, the N+1 query problem, and above all why `@Transactional` fails on a self-invoked method.
Why does @Transactional not work on internal method calls?
Spring applies the annotation through a proxy that wraps the bean. When one method in a class calls another directly, the call never leaves the object, so the proxy is never involved and no transaction is started. The same limitation affects `@Cacheable` and `@Async`.
Does Spring roll back on checked exceptions?
Not by default - only unchecked exceptions and errors trigger rollback. To roll back on a checked exception you must declare it with `rollbackFor`. This default surprises candidates regularly and is a common interview check.
What is the N+1 problem in JPA?
Loading a collection of entities with one query, then issuing a further query per entity to load a lazy association - one query becomes N+1. It is usually fixed with a join fetch, an entity graph, or batch fetching, and detected by logging the generated SQL.
Walk into the round with a second pair of eyes
CoPilot Interview is a native Windows and macOS app that puts suggested answers on your own screen in about two seconds, across coding, system design and behavioral rounds. The free tier is permanent: 15 minutes a day, no credit card.
Try it free