Skill-
Forge
Learn
Notes
Language & Framework notes
CS Core Subjects
OS, DBMS, Networks, OOP & more
System Design
Architecture & High-Scale
Roadmaps
Guided developer learning paths
Cheat Sheets
Quick syntax references
Resources
Curated books, guides & links
Practice
Problems
DSA & coding challenges
Quizzes
Test your knowledge
Algorithms
Explanations & visualizations
Git Visualizer
Interactive Git graph & CLI playground
Aptitude
Placement & logic prep
Formula Simulators
Real-time quant equation simulators
Build
Projects Hub
Step-by-step real world projects
Resume Builder
ATS-friendly resumes, live preview & score
Tools
Online compilers & utilities
Skills
Core professional & tech skills
Error Encyclopedia
Search
⌘K
Install App
Start Learning
Menu
Learn
Notes
CS Core Subjects
System Design
Roadmaps
Cheat Sheets
Resources
Practice
Problems
Quizzes
Algorithms
Git Visualizer
Aptitude
Formula Simulators
Build
Projects Hub
Resume Builder
Tools
Skills
Error Encyclopedia
Search
Install Skill-Forge App
Appearance
Start Learning
Skip to main content
Cheatsheets
13 sections
49 cards
Spring Boot 3.x · Java 17+ · Jakarta EE · Spring 6
🍃
Spring Boot Cheat Sheet
Complete reference — Annotations · REST · JPA · Security · Testing · Actuator
Browse sections
Shortcuts
?
Hide Sidebar
Search cheatsheet sections
/
or
⌘K
Progress
0%
Table of contents
Shortcuts
?
🧠
Core Concepts & Mental Model
🚀
Setup & Project Structure
🏷️
Annotations Quick Reference
🔧
Dependency Injection
⚙️
Configuration (application.properties)
🔗
REST Controllers & HTTP
🗄️
JPA & Spring Data
🔐
Spring Security
⚠️
Exception Handling
📊
Spring Boot Actuator
🧪
Testing
✨
Common Patterns & Best Practices
🎯
Interview Q&A & Gotchas
J
K
Jump
/
Search
Esc
Clear
🧠
Core Concepts & Mental Model
What is Spring Boot?
Opinionated wrapper around the Spring Framework
Auto-configuration based on classpath + beans present
Embedded server (Tomcat/Jetty/Undertow) — no WAR deployment needed
Production-ready via Actuator metrics & health endpoints
Convention over configuration — zero XML required
Spring Application Lifecycle
IoC Container & Bean Scopes
Key Spring Layers
🚀
Setup & Project Structure
Maven pom.xml — Essential Dependencies
Standard Folder Structure
Main Application Class
🏷️
Annotations Quick Reference
Stereotype & Bean Annotations
Web / REST Annotations
JPA / Entity Annotations
Misc Important Annotations
Validation Annotations (jakarta.validation)
🔥 Annotation Combinations to Know
🔧
Dependency Injection
Constructor Injection (Preferred ⭐)
Field & Setter Injection (Avoid in prod)
@Configuration Bean Factory
@Value & @ConfigurationProperties
⚙️
Configuration (application.properties)
Server & App Properties
DataSource / JPA Properties
Logging & Actuator
Profiles — Multi-env Config
🔗
REST Controllers & HTTP
Full CRUD Controller
ResponseEntity & HTTP Status Codes
HTTP Status Code Summary
🗄️
JPA & Spring Data
Entity Class
JpaRepository — Built-in Methods
Relationships
Pagination & Sorting
@Transactional — Key Rules 🔥
🔐
Spring Security
SecurityFilterChain (Spring Boot 3.x / Spring 6)
UserDetailsService Implementation
JWT Filter (Skeleton)
Method-Level Security
⚠️
Exception Handling
Global Exception Handler
Custom Exception Classes
📊
Spring Boot Actuator
Common Endpoints
Custom Health Indicator & Config
🧪
Testing
Unit Test — Service Layer (Mockito)
Integration Test — Controller (@WebMvcTest)
Test Annotations Cheat Table
✨
Common Patterns & Best Practices
DTO Pattern (Records — Java 16+)
@Scheduled Tasks
@Async Background Processing
CommandLineRunner & ApplicationRunner
🎯
Interview Q&A & Gotchas
🔥 Top Interview Questions
<strong>What does @SpringBootApplication do?</strong> — Combines @Configuration + @EnableAutoConfiguration + @ComponentScan
<strong>Difference: @Component vs @Service vs @Repository?</strong> — All are @Component; @Repository adds exception translation, @Service is semantic
<strong>What is Spring IoC?</strong> — Inversion of Control: Spring manages object lifecycle & dependencies, not your code
<strong>Constructor vs Field injection?</strong> — Constructor is preferred: immutable, testable, required deps explicit
<strong>How does auto-configuration work?</strong> — Reads spring.factories (now AutoConfiguration.imports), conditionally registers beans
<strong>What is @Transactional propagation?</strong> — REQUIRED (default), REQUIRES_NEW, NESTED, SUPPORTS, MANDATORY, NOT_SUPPORTED, NEVER
<strong>EAGER vs LAZY fetching?</strong> — EAGER loads related entities immediately; LAZY loads on access. LAZY is default for @OneToMany
<strong>What is N+1 problem?</strong> — Loading 1 entity causes N extra queries for associations. Fix: JOIN FETCH in JPQL or @EntityGraph
<strong>How does Spring Security work?</strong> — FilterChain processes each request; filters authenticate/authorize before hitting controller
⚡ Common Gotchas & Pitfalls
@Transactional only works on <strong>public</strong> methods — private methods are not proxied
Self-invocation bypasses proxy — calling @Transactional method from same class skips transaction
@Async has same proxy limitation — cannot call async methods from same bean
Circular dependencies in constructor injection → BeanCurrentlyInCreationException. Use setter or @Lazy
@OneToMany without mappedBy creates an unwanted join table
Using EAGER fetch on @OneToMany = N+1 problem by default
Bidirectional relationships need helper methods to sync both sides
@MockBean resets application context — slows tests. Use judiciously
spring.jpa.hibernate.ddl-auto=create-drop in prod = data loss 💀
@Value doesn't work in static fields — inject into non-static and use manually
Bean Lifecycle & @PostConstruct vs @PreDestroy
Quick Comparison Table
Transactional Propagation Levels