Quick revision
The short answer
I use @ConfigurationProperties whenever a feature has a group of related settings: it binds them to one typed object, including nested objects and lists, supports relaxed binding from environment variables, validation with @Validated, IDE completion through generated metadata, and immutable records or constructor binding. @Value remains fine for one or two simple values and is the only one of the two that supports SpEL. Grouped properties also make configuration easier to review and document.
What to remember
In this answer, we compared @Value and @ConfigurationProperties. @ConfigurationProperties binds a group of related settings to one typed object with nested objects and lists, fully relaxed names for environment variables, validation at startup with @Validated, generated metadata for IDEs and documentation, and immutability through records or constructor binding. @Value stays useful for a single value and for SpEL. Grouping settings per feature makes configuration easier to review, operate and document.
Your turn
Answer it aloud as you would in the interview, or type your answer below. Then show one part at a time and compare.
I use @ConfigurationProperties whenever a feature has a group of related settings: it binds them to one typed object, including nested objects and lists, supports relaxed binding from environment variables, validation with @Validated, IDE completion through generated metadata, and immutable records or constructor binding. @Value remains fine for one or two simple values and is the only one of the two that supports SpEL. Grouped properties also make configuration easier to review and document.
Why this question is asked
Every Spring Boot application reads configuration, and the way we read it shapes how easy the application is to configure, test and operate. A codebase where forty @Value annotations are scattered across twenty classes is hard to review: nobody can see what a feature needs, mistakes show up as runtime errors, and operators guess at variable names. Interviewers ask this design question to see whether we know what each mechanism offers and choose deliberately. In this answer, we will recap both mechanisms, show the same configuration both ways, then go through binding, relaxed names, validation, metadata and immutability, and finish with when @Value is still the better choice.
1A Quick Recap of Both Mechanisms
@Value injects one value, written as a placeholder such as ${app.timeout}, into one field or parameter. Each annotation stands alone: it names its key, it may give a default, and Spring converts the text to the field's type.
@ConfigurationProperties takes a prefix, such as payments.client, and binds every property under that prefix to the fields or constructor parameters of one class. The class is registered as a bean with @EnableConfigurationProperties or @ConfigurationPropertiesScan, and other beans inject it like any other dependency. Binding is done by Spring Boot's Binder, which understands nested objects, lists, maps and many value types.
2The Same Settings Both Ways
Here is a payment client with five settings, first with @Value and then with a record bound by @ConfigurationProperties.
Notice what the second version gives us for free. The settings of the feature live in one place with their types and defaults. The nested auth block becomes a nested record. The list becomes a typed List<Currency>, so a misspelled currency code fails at startup. And the client takes one parameter instead of five.
3Relaxed Binding and Validation
Relaxed binding means the binder accepts several spellings of the same property name. payments.client.base-url in YAML, PAYMENTS_CLIENT_BASEURL as an environment variable and payments.client.baseUrl in a properties file all bind to the same baseUrl field. This matters in containers, where operators usually set environment variables, which cannot contain dots or dashes. @Value supports only limited relaxed matching, and the Spring Boot documentation recommends referring to keys in their kebab-case form there; @ConfigurationProperties is fully relaxed.
Validation comes from adding @Validated and Jakarta Bean Validation annotations such as @NotNull or @Min. Spring Boot validates the object when it binds it, at startup, and refuses to start with a message that names the property and the rule it broke. A wrong value then fails during deployment, where it is cheap to fix, instead of on the first payment request at night.
4Metadata and Immutability
If we add the spring-boot-configuration-processor dependency as an annotation processor, the build generates a metadata file, META-INF/spring-configuration-metadata.json, describing every property with its type, default and Javadoc description. IDEs use it for completion and warnings in application.yml, and it doubles as documentation of everything a module can be configured with. @Value keys get no metadata, because they are just strings inside annotations.
Records, or classes with a single constructor, use constructor binding: Boot passes the values to the constructor, so the object is immutable once created. Nobody can change a timeout at run time by calling a setter, and the object can be shared safely between threads. Since Spring Boot 3, a single constructor is used automatically, and @DefaultValue supplies defaults for constructor parameters.
5When @Value Is Still the Right Choice
@Value is not wrong. For one or two unrelated values in a single class, such as a scheduler's cron expression, a whole properties class is more ceremony than it is worth. @Value is also the only option when we need SpEL, for example to compute a value from two properties or call a static method, because @ConfigurationProperties binding does not evaluate expressions. And @Value can be used directly in a test or a small application without registering anything.
| Need | @Value | @ConfigurationProperties |
|---|---|---|
| One or two simple values | Good fit | Works, more ceremony |
| A group of related settings | Scattered keys | One typed object |
| Nested objects, lists, maps | Awkward | Native support |
| Environment variable spellings | Limited relaxed binding | Fully relaxed |
| Validation at startup | Manual | @Validated with constraints |
| IDE completion and docs | None | Generated metadata |
| SpEL expressions | Supported | Not supported |
6Why Grouping Helps Review and Operations
The strongest argument is about people, not code. When a feature's settings are one class, a reviewer can see every knob the change introduced, its type, its default and its limits in one diff. An operator can look at the configprops actuator endpoint and see the bound values grouped by feature. And when we write documentation or a runbook, the metadata already lists the properties. So my rule is: one @ConfigurationProperties class per feature or external system, and @Value only for the occasional single value or when SpEL is needed.
7Follow-up questions
Can @ConfigurationProperties classes be used outside Spring beans?
They are ordinary classes or records, so we can construct them directly in unit tests, which is one of their advantages. Binding from properties, however, needs Spring Boot's Binder, either through the application context or by calling Binder.get(environment).bind("prefix", MyProps.class) ourselves.
Does @ConfigurationProperties work with configuration that changes at runtime?
Bound objects are created once at startup. Spring Cloud's refresh scope can rebind mutable properties classes when configuration changes, but immutable records are not rebound in place. For values that really change at run time, a feature flag service is usually a better tool than refreshing configuration.
Why is a property name like payments.client.baseUrl discouraged in YAML?
It works because of relaxed binding, but the canonical form is kebab-case, payments.client.base-url. Using the canonical form everywhere keeps files consistent, matches the generated metadata, and works with @Value too, which only reliably supports kebab-case keys.
8Conclusion
In this answer, we compared @Value and @ConfigurationProperties. @ConfigurationProperties binds a group of related settings to one typed object with nested objects and lists, fully relaxed names for environment variables, validation at startup with @Validated, generated metadata for IDEs and documentation, and immutability through records or constructor binding. @Value stays useful for a single value and for SpEL. Grouping settings per feature makes configuration easier to review, operate and document.
Open with
I reach for ConfigurationProperties as soon as a feature has a group of related settings, for example a client with a base URL, timeout, retries and credentials. It binds everything under a prefix to one typed object, including nested objects, lists and maps, so the feature's configuration lives in one class with its types and defaults.
Then, if they want more
It has fully relaxed binding, which matters in containers where operators set environment variables like PAYMENTS_CLIENT_BASEURL. With Validated and Bean Validation constraints, wrong values fail at startup with a clear message naming the property. The configuration processor generates metadata for IDE completion and documentation. And with a record or a single constructor, the object is immutable, using DefaultValue for defaults.
Value is still fine for one or two simple values in a single class, and it is the only option when I need a SpEL expression, because property binding does not evaluate SpEL. Its relaxed binding is limited, so I always use kebab-case keys there.
The bigger reason for grouping is review and operations: a reviewer sees every new setting with its limits in one diff, the configprops endpoint shows values per feature, and the metadata documents them. So my rule is one properties class per feature or external system, and Value only for the odd single value or SpEL.
About this answer
- Last updated
- 12 November 2026
- Versions it names
- Spring Boot 3
- Checked
- Its structure and format are checked automatically. Use it as a carefully prepared study note: where a detail matters, confirm it against the documentation below. What the checks cover
- Where the question comes from
- Written by Scrivio for practice. It is not taken from an interview.
- Official documentation
- Spring Framework reference, Core technologies
Report an issue with this answer
Copy the line below and send it to the author with what you found. It carries the address of this page.
Issue with "When would you use @ConfigurationProperties instead of @Value, and why?": https://scrivio-interview-library.netlify.app/spring-boot/spring-configuration/64162d7386/