This is the short version of Spring. Not a tour of everything the framework can do — the set of questions you are expected to be able to answer about it, answered directly, with code that compiles.
It is written as questions and answers on purpose. That is how the knowledge actually gets used: in an interview, in a design review, or at the moment you are staring at an annotation that is silently doing nothing.
Who this is for
- You have written some Spring and want the gaps filled in — you use
@Transactionalbut could not say what it generates. - You are interviewing, on either side of the table.
- You learned Spring years ago and want to know what has changed. A lot has.
If you have never written a Spring application at all, start with the Spring Boot track and come back here. That one builds things; this one explains them.
Versions
Every answer here is written against these. This matters more than it usually does, because several of the standard answers to these questions changed in Spring 6 and again in Spring 7 — an answer that was right in 2019 is now wrong.
| What | Version |
|---|---|
| Spring Framework | 7.0.8 |
| Spring Boot | 4.1.0 |
| Java | 21 |
| Jakarta EE | 11 — jakarta.*, never javax.* |
| JUnit | 5 (Jupiter) |
The eight topics
- Core Spring — the container, beans, dependency injection, configuration, proxies.
- AOP — cross-cutting concerns, and the proxy rule that explains half of Spring's surprises.
- Data Integration — JdbcTemplate, transactions, JPA, Spring Data.
- Spring Boot — starters, auto-configuration, properties.
- Web Layer — the DispatcherServlet and Spring MVC.
- REST — resources, verbs, status codes, message converters.
- Security — the filter chain, authentication, authorisation.
- Testing — what needs Spring and what does not.
Read in that order the first time. After that, each one stands alone.
Where the code comes from
Every snippet is lifted from one real application — a pizza ordering API: menu, cart, guest checkout, Stripe payments, JWT authentication, an admin back office and reporting. Around 130 classes and a test suite that runs green.
That constraint is deliberate. Invented snippets can demonstrate an annotation without ever
having been compiled, and they never show the awkward parts. When you see
@Transactional(readOnly = true) below, it is on a method that really runs.
What changed since Spring 5 — read this before trusting an old answer
Most Spring study material online predates Spring 6. Here is what will make it wrong.
| Then | Now |
|---|---|
javax.persistence, javax.servlet |
jakarta.*. Spring 6 moved the whole namespace. Nothing that imports
javax compiles. |
WebSecurityConfigurerAdapter |
Gone. Publish a SecurityFilterChain bean instead, configured with the lambda DSL.
Spring Security 7 removed the chained-setter style entirely. |
RestTemplate |
RestClient for synchronous calls, WebClient for reactive.
RestTemplate still works and is still maintained, but it is not the answer to
"which client would you use". |
@MockBean |
@MockitoBean. Deprecated in Boot 3.4, and the replacement lives in
org.springframework.test.context.bean.override.mockito. |
spring-boot-starter-web |
spring-boot-starter-webmvc. The old name still resolves in Boot 4 — it is
deprecated, not removed, so this one does not break your build. |
spring-boot-starter-aop |
spring-boot-starter-aspectj. Unlike the one above, the old name is gone from the
BOM entirely, so a Boot 3 pom fails with "version is missing" — an error that never
mentions the rename. |
spring-retry + @EnableRetry |
Retry is in the core container. @Retryable now lives in
org.springframework.resilience.annotation, switched on with
@EnableResilientMethods. No extra dependency. |
@RunWith(SpringRunner.class), JUnit 4 |
JUnit 5. @SpringBootTest brings the Spring extension with it — no runner, no
@ExtendWith to write. |
One spring-boot-autoconfigure jar |
Boot 4 split auto-configuration into per-technology modules, so packages moved. For example
AutoConfigureMockMvc is now
org.springframework.boot.webmvc.test.autoconfigure. |
None of these change the concepts. All of them change the code you would write on a whiteboard.
How to use this guide
Read the question, answer it out loud before reading on, then compare. The gap between "I recognise this" and "I can explain this" is the entire point, and it only shows up when you try to say it.