@ConfigurationProperties binds a group of external properties, such as those in application.yml or environment variables, to a typed Java object. You get type conversion, nested structures, validation and IDE auto-completion, which is far more maintainable than scattering @Value annotations across your code.
It is a Spring Boot feature (org.springframework.boot.context.properties) and is the recommended way to read application configuration in Spring Boot 3 and later.
You declare a class, give it a prefix, and Spring Boot's Binder fills it from the Environment. All property sources take part: command line arguments, environment variables, system properties, profile-specific files and application.properties or application.yml.
Benefits compared with @Value:
app.max-retries, app.maxRetries and APP_MAXRETRIES all map to maxRetriesDuration, DataSize, enums, lists, maps and nested objectsSince Spring Boot 3, classes with a single constructor, including records, bind through the constructor with no extra annotation. This gives immutable configuration.
timeout: 10s is converted to a Duration automatically, and ${MAIL_PASSWORD} is resolved from the environment. When a property is missing, a primitive gets its default and @DefaultValue supplies another value.
A properties class is not a bean until you register it. Choose one approach.
You can also annotate a @Bean method or a @Component class with @ConfigurationProperties. In the @Component case use JavaBean (setter) binding, since constructor binding needs the class registered through scanning or @EnableConfigurationProperties.
The older style uses a class with getters and setters. It still works and is needed for mutable collections you want to modify.
If a class has several constructors, mark the one to use with @ConstructorBinding; otherwise Boot uses setter binding.
Add @Validated and Jakarta Bean Validation constraints so the application fails fast on bad configuration.
You need a validator implementation such as spring-boot-starter-validation on the classpath. If host is blank, startup stops with a message naming the offending property. Add @Valid on nested objects to validate them too.
Add the annotation processor to produce META-INF/spring-configuration-metadata.json, which gives your IDE completion and Javadoc for custom properties.
| Feature | @ConfigurationProperties | @Value |
|---|---|---|
| Binds a group of properties | Yes | One at a time |
| Relaxed binding | Full | Limited |
| Nested objects, lists, maps | Yes | Awkward |
| Validation | Yes | No |
| SpEL expressions | No | Yes |
| IDE metadata | Yes | No |
Use @Value for a single, simple value or when you need SpEL. Use @ConfigurationProperties for everything else.
Only if the class is not discovered another way. Use @ConfigurationPropertiesScan on your application class to register all properties classes in the package tree, or list individual classes with @EnableConfigurationProperties.
The usual causes are a wrong prefix, a class that is not registered as a bean, missing setters in JavaBean style, or a kebab-case versus camelCase typo. Enable debug=true or inspect the /actuator/configprops endpoint to see what bound.
Yes. Records bind through their canonical constructor in Spring Boot 3 and later, which makes configuration immutable.
Use profile files such as application-prod.yml, environment variables or command line arguments. They override the default file because property source precedence is defined by Spring Boot.
@ConfigurationProperties maps a prefix of your configuration to a typed object with relaxed binding, conversion and validation. Prefer records with constructor binding, register them with @ConfigurationPropertiesScan or @EnableConfigurationProperties, validate with @Validated, and keep @Value for single values.