# Spring Boot — Production-Grade Java Apps with Minimum Fuss > Spring Boot makes it easy to create stand-alone, production-grade Spring-based applications. Auto-configuration, embedded servers, actuator endpoints, and a massive starter ecosystem. The dominant framework for enterprise Java backends. ## Install Save in your project root: ## Quick Use ```bash # Use Spring Initializr curl https://start.spring.io/starter.zip \ -d type=maven-project -d language=java -d javaVersion=21 \ -d dependencies=web,data-jpa,h2 \ -d name=demo -o demo.zip unzip demo.zip && cd demo ./mvnw spring-boot:run # Visit http://localhost:8080 ``` Or use https://start.spring.io web UI. Minimal REST controller: ```java @RestController @RequestMapping("/api/assets") public class AssetController { @Autowired private AssetRepository repo; @GetMapping public List list() { return repo.findAll(Sort.by("stars").descending()); } @PostMapping public Asset create(@RequestBody Asset asset) { return repo.save(asset); } } @Entity public class Asset { @Id @GeneratedValue private Long id; private String name; private int stars; // getters, setters } public interface AssetRepository extends JpaRepository {} ``` ## Intro Spring Boot is a project by VMware (now Broadcom) that simplifies building production-grade Spring-based applications. Auto-configuration, embedded servers (Tomcat/Jetty/Undertow), actuator monitoring endpoints, and a massive starter dependency ecosystem. The dominant framework for enterprise Java and Kotlin backends. - **Repo**: https://github.com/spring-projects/spring-boot - **Stars**: 80K+ - **Language**: Java - **License**: Apache 2.0 ## What Spring Boot Does - **Auto-configuration** — detect classpath and wire beans automatically - **Embedded server** — Tomcat, Jetty, or Undertow built in (no WAR deploy) - **Starters** — spring-boot-starter-web, -data-jpa, -security, -actuator - **Actuator** — health, metrics, info, env, configprops endpoints - **Spring Data JPA** — repository interfaces auto-implement CRUD - **Spring Security** — auth, authorization, OAuth2, CORS, CSRF - **Spring MVC** — annotation-driven REST controllers - **Spring WebFlux** — reactive non-blocking stack - **Profiles** — dev/test/prod environment configuration - **GraalVM native** — compile to native binary (Spring AOT) ## Architecture Spring IoC container manages beans. Auto-configuration inspects the classpath and conditionally registers beans. Starters bring in curated dependency sets. Actuator exposes operational endpoints. Configuration via `application.yml` / `application.properties` with profiles. ## Self-Hosting ```bash # Build executable JAR ./mvnw package -DskipTests java -jar target/demo-0.0.1-SNAPSHOT.jar # Docker FROM eclipse-temurin:21-jre COPY target/*.jar app.jar ENTRYPOINT ["java", "-jar", "app.jar"] # Native image ./mvnw -Pnative native:compile ./target/demo # ~30ms startup ``` ## Key Features - Auto-configuration - Embedded server - 80+ official starters - Spring Data (JPA, MongoDB, Redis, Elasticsearch) - Spring Security - Spring Actuator - Spring WebFlux (reactive) - GraalVM native compilation - Profiles for environment config - Excellent documentation and guides ## Comparison | Framework | Language | Config | Best For | |---|---|---|---| | Spring Boot | Java/Kotlin | Auto-config | Enterprise | | Quarkus | Java/Kotlin | CDI | Cloud-native | | Micronaut | Java/Kotlin | Compile-time DI | Serverless | | NestJS | TypeScript | Decorators + DI | Node enterprise | | Django | Python | settings.py | Full stack | | Rails | Ruby | Convention | Full stack | ## 常见问题 FAQ **Q: Spring Boot vs Spring Framework?** A: Spring Framework 是底层 IoC + AOP + MVC。Spring Boot 是上面一层:自动配置、starter、embedded server,让你不用写 XML 和复杂 bean 配置。 **Q: 启动慢?** A: JVM 启动确实慢(1-5s)。解决方案:Spring AOT + GraalVM Native Image 可以把启动时间降到 30-50ms。 **Q: 和 Quarkus 比?** A: Quarkus 专为云原生优化(更快启动、更小 RSS);Spring Boot 生态最大、企业经验最多。中大型团队多数仍选 Spring Boot。 ## 来源与致谢 Sources - Docs: https://docs.spring.io/spring-boot/docs - GitHub: https://github.com/spring-projects/spring-boot - License: Apache 2.0 --- Source: https://tokrepo.com/en/workflows/cc16509a-362e-11f1-9bc6-00163e2b0d79 Author: AI Open Source