The 30 second answer
Spring Boot supports many cloud-native practices without making them automatic. I can use the same artifact across environments, externalize configuration, connect to backing services, write logs to standard output and shut down gracefully. It also supports Kubernetes liveness and readiness probes, mounted configuration and secrets, and buildpack-based container images. Native images are another option when startup time matters. Those are practical reasons to choose it, but good deployment design and sensible operational settings still matter.
Go through the Twelve-Factor list and show the Spring Boot feature for each:
| Factor | Spring Boot feature |
|---|---|
| III. Config in the environment | Relaxed binding: SPRING_DATASOURCE_URL sets spring.datasource.url; spring.config.import=configtree:/etc/secrets/ reads mounted Kubernetes secrets |
| IV. Backing services | A database, broker or cache is just a URL and credentials in properties; swap them without code changes |
| V. Build, release, run | One executable JAR or image; config is applied at run time |
| VI. Stateless processes | Nothing forces server state; session data can move to Redis with Spring Session |
| VII. Port binding | Embedded server; server.port or SERVER_PORT |
| IX. Disposability | Graceful shutdown waits for in-flight requests; startup can be cut with AOT, CDS or native images |
| X. Dev/prod parity | Docker Compose and Testcontainers support start the same databases locally and in tests |
| XI. Logs as event streams | Logs go to the console by default; structured JSON formats are built in |
Kubernetes specifics:
- Probes. When Spring Boot detects it is running on Kubernetes (it checks for
*_SERVICE_HOSTand*_SERVICE_PORTenvironment variables), Actuator addslivenessandreadinesshealth groups. Readiness becomesACCEPTING_TRAFFIConly after the app is ready, and turnsREFUSING_TRAFFICduring shutdown.
livenessProbe:
httpGet: { path: /actuator/health/liveness, port: 8080 }
readinessProbe:
httpGet: { path: /actuator/health/readiness, port: 8080 }- Images.
mvn spring-boot:build-imageorgradle bootBuildImagebuilds an OCI image with Cloud Native Buildpacks. - Observability. Micrometer metrics and tracing export to Prometheus or OpenTelemetry.
Editor's note: be honest about limits. Twelve-Factor is a guideline from 2011, not a standard, and Spring Boot does not make an app stateless by itself; you still have to design it that way.
Sources (4)
- The Twelve-Factor App12factor.net
- Spring Boot reference: Deploying to Kubernetesdocs.spring.io
- Spring Boot reference: Kubernetes probesdocs.spring.io
- Spring Boot reference: Configuration treesdocs.spring.io