Spring Boot is an opinionated framework built on top of the Spring Framework that simplifies Java application development by providing auto-configuration, embedded servers, and production-ready features out of the box. It eliminates the need for extensive XML configuration and boilerplate code, enabling developers to create stand-alone, production-grade applications with minimal setup. Spring Boot's philosophy centers on convention over configuration, allowing you to quickly bootstrap microservices, REST APIs, and enterprise applications while maintaining the flexibility to override defaults when needed. With Spring Boot 3.x requiring Java 17+ and Jakarta EE 9+, the framework now natively supports GraalVM native images, virtual threads (Project Loom), and the Micrometer observability stack, making it well-suited for cloud-native, high-concurrency workloads.
What This Cheat Sheet Covers
This topic spans 27 focused tables and 178 indexed concepts. Below is a complete table-by-table outline of this topic, spanning foundational concepts through advanced details.
Table 1: Core Annotations
| Annotation | Example | Description |
|---|---|---|
public class App { public static void main(String[] args) { SpringApplication.run(App.class, args); }} | Combines @Configuration, @EnableAutoConfiguration, and @ComponentScan β marks the main entry point and triggers auto-configuration based on classpath dependencies. | |
public class UserController { public List<User> getUsers() {...}} | β’ Combines @Controller and @ResponseBody β’ marks a class as a RESTful controller and automatically serializes return values to JSON/XML. | |
public class EmailService { public void send(String msg) {...}} | Marks a class as a Spring-managed bean β automatically detected via classpath scanning and registered in the application context. | |
public class UserService { public User findById(Long id) {...}} | Specialization of @Component for service-layer classes containing business logic β semantically signals intent. | |
public interface UserRepository extends JpaRepository<User, Long> {} | Specialization of @Component for data-access classes β enables exception translation from database errors to Spring's DataAccessException hierarchy. | |
public class AppConfig { public DataSource dataSource() {...}} | Indicates a class declares @Bean methods that Spring processes at runtime to generate bean definitions. | |
public RestClient restClient() { return RestClient.create();} | Declares a method that produces a Spring-managed bean β used within @Configuration classes to define custom beans. | |
private final UserService userService;public UserController(UserService userService) { this.userService = userService;} | Enables automatic dependency injection by type β prefer constructor injection (shown) over field injection for testability and immutability. |