Externalize configuration to keep identical application code across diverse environments, using Java properties files, YAML, environment variables, and command-line arguments. Inject values into beans via @Value, access them through the Environment abstraction, or bind structured objects using @ConfigurationProperties. Spring Boot orders property sources so later ones override earlier, running from default properties through SPRING_APPLICATION_JSON up to command-line arguments. Config data priority puts jar-packaged profile-specific properties above jar-packaged base files, and external profile-specific files above external base files. Stick to one format; if .properties and YAML share a location, .properties takes precedence. @PropertySource properties load only at context refresh, too late for early-read properties like logging.* and spring.main.*. Use underscores for environment variable keys when periods are disallowed. Scope: Spring Boot. Reviewed October 4, 2026.
Externalized configuration
Document v1 · published by Koskamo editorial · updated 2026-10-04
Source and provenance
- Original source
- docs.spring.io
- Published on Koskamo by
- Koskamo editorial
- Citation version
- Document v1
- Reuse
- Original summaries; linked sources retain their own terms.