configuration-properties
Configuration Properties
Spring Boot 3 baseline
The examples use Java 17 and Jakarta APIs supported by this Boot version. Keep dependencies managed by the project's Boot BOM.
Bind and validate
Inspect existing property prefixes and external deployment configuration before renaming keys. Use a typed ConfigurationProperties record for a related group of settings. Register it with EnableConfigurationProperties or ConfigurationPropertiesScan; a record is not automatically a bean. Use Validated and Jakarta constraints, and include spring-boot-starter-validation. Validate nested objects with Valid. A single record constructor needs no ConstructorBinding annotation.
Use explicit units for durations and sizes. Provide defaults only when they are operationally safe; missing credentials or required endpoints should fail startup. Do not assume NotNull rejects zero or negative Duration values; add a duration constraint or an explicit invariant.