Path 5 of 5
Spring and JPA in Production
Five things that work in development and surprise you in production: transactions that never start, the wrong bean injected, exceptions nobody sees, a 45-second startup and a lazy collection read too late.
0 / 5 lessons completed · about 84 min in total
After this path you can
Outcomes
- Say when a call reaches the Spring proxy and when it goes around it
- Predict which of two beans Spring injects, or why it refuses
- Find where the exception of an asynchronous method went
- Measure a slow startup and fetch lazy data without leaving a session open
Lessons
- 1@Transactional that silently does nothingA transaction starts in a proxy that stands in front of your bean. A private method, or a call from inside the same class, never reaches that proxy, and nothing tells you.Intermediate18 min
- 2Two beans of one type: which one is injectedSpring narrows the candidates by qualifier, then by @Primary, then by name, and refuses to start when more than one is left. The order decides which bean you silently get.Foundation15 min
- 3@Async: where the exception goesThe caller of an @Async method has already moved on when it fails. A void method leaves one log line, a future that nobody reads leaves nothing, and the default queue has no limit.Intermediate17 min
- 4A 45-second startup: measure, then cutStartup time is mostly a handful of beans doing slow work while the context is built. Record the startup steps, sort by duration, and fix the top of the list before touching anything else.Intermediate16 min
- 5LazyInitializationException in production onlyA lazy collection can only load while its session is open. Spring Boot keeps one open for every web request by default, which hides the problem until the same code runs anywhere else.Intermediate18 min