Spring Boot provides comprehensive externalized configuration support that lets a single application artifact run in different environments by sourcing values from multiple origins.
A THREE-CATEGORY MODEL FOR CONFIGURATION
The best practices outline classifying configuration into three categories: TechStaged has also covered Google Play sweeps players into a vault of prizes with Play Points.
- Application defaults: safe, non-secret values such as service URLs, timeouts, and retry limits (stored with the application).
- Deployment configuration: environment identifiers like database hosts and external service URLs (supplied through the deployment platform).
- Secrets: passwords, API keys, certificates, and private keys (stored in a dedicated secrets system).
- Application defaults should be safe and typically stored with the application.
- Deployment configuration identifies the environment and is provided via deployment tooling or platforms.
- Secrets should never be kept in source control and should reside in a dedicated secrets-management system.
BIND CONFIGURATION WITH TYPE SAFETY AND CLARITY
Spring applications access configuration via Environment, @Value, or @ConfigurationProperties. The guidance favors @ConfigurationProperties for maintaining related properties together, offering relaxed binding, IDE metadata, and easier discovery and refactoring.
Using a Java record for @ConfigurationProperties is recommended for immutability, helping to prevent accidental modifications after startup.
- Prefer @ConfigurationProperties to scattered @Value usage.
- Consider @ConfigurationPropertiesScan to register configuration types.
- Relaxed binding maps canonical names to Java fields (e.g., base-url to baseUrl).
VALIDATE EARLY; FAIL FAST ON STARTUP
Configuration errors should be detected at startup. Annotate @ConfigurationProperties with @Validated and apply Jakarta Bean Validation constraints to enforce required values, numeric ranges, and nested group constraints.
Use wrapper types (e.g., Integer with @NotNull) to distinguish between a missing value and a Java default.
- Enable startup validation with spring-boot-starter-validation.
- Validate required values to fail early if configuration is incomplete.
UNDERSTAND PROPERTY SOURCE PRECEDENCE
Spring Boot aggregates configuration from multiple sources. The effective value comes from the source with higher precedence, which is important when troubleshooting unexpected values.
Environment variables are widely supported and transformed to uppercase names with underscores to align with Spring Boot’s property naming.
- Be aware of how precedence can alter effective configuration values.
- IntelliJ IDEA can show which source provides a given value and indicate overrides.
STORE SECRETS SECURELY AND MINIMIZE EXPOSURE
Do not store sensitive values in source control or in logs. Use a dedicated secret-management system such as a cloud secret manager or an on-premises vault, and restrict access to management endpoints to protect secrets in runtime environments.
- Use Vault, AWS Secrets Manager, Google Cloud Secret Manager, or similar.
- Exclude secrets from logs and metadata in public interfaces.
CONFIGURATION STRATEGIES TAILORED TO DEPLOYMENT MODELS
There is no single universal approach. For monoliths, keep shared defaults in the application and use environment overrides for deployment specifics; for Kubernetes, use ConfigMaps for non-sensitive values and a secret-management system for secrets; for microservices, consider centralizing config with a server like Spring Cloud Config Server and still manage secrets separately.
- Monoliths: defaults in-app, environment overrides for deployment specifics.
- Kubernetes: ConfigMaps for deployment-time values; secrets in secret stores.
- Microservices: centralize with a config server; externalize secrets.
DEVELOPER TOOLING AND TRANSPARENCY
Development environments, IDEs like IntelliJ IDEA, can help reveal the effective configuration by showing resolved values and their sources, including whether a value is overridden by environment variables or system properties.
IDE features may include metadata-assisted navigation and hints about property declarations and usages.
- Leverage IDE-assisted visibility to troubleshoot configuration issues.
- Check how environment variables influence the final values during development.
RELATED COVERAGE
SOURCES
- The JetBrains Blog: Spring Boot Configuration Management Best Practices Published · Primary source








