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
# 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 startupKey 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