S

Spring & Spring Boot

Cheat Sheet · Quick Reference

v3.x / Boot 3.x

Evolution

Servlet

Java class extending HttpServlet. Runs in Web Container (Tomcat). Lifecycle: init() → service() → destroy()

JSP

HTML with embedded Java (<% %>). Compiled to Servlet behind the scenes. Led to spaghetti code → MVC pattern.

EJB

Session Beans (Stateless/Stateful/Singleton), Message-Driven (JMS), Entity Beans (→ JPA). Required heavy app servers (WebSphere, WebLogic).

Spring

POJOs + IoC + DI. No heavy server needed. Replaced XML config with annotations. Eliminated EJB bloat.

Spring Boot

Wrapper over Spring. Kills boilerplate. Embedded Tomcat. Eager bean creation (all singletons at startup).

Tomcat vs Nginx

Nginx

Web server. Fast for static files, SSL termination, reverse proxy. Sits in front.

Tomcat

App server. Executes Java, talks to DB, generates responses. Slower for static content.

Together

Nginx → static files instantly. Dynamic req → Nginx proxies to Tomcat (internal network) → Tomcat → Nginx → User.

Self-Injection fix
@Lazy on @Autowired setter — for @Transactional proxy bypass
BeanPostProcessor
Intercepts ALL beans. postProcessBefore/AfterInitialization()
CGLIB vs JDK Proxy
JDK: bean implements interface. CGLIB: no interface, subclass at runtime
@Order vs Ordered
Controls execution order of Filters/Interceptors — NOT bean creation order