Scrivio Interview library
ConceptFoundations5 min read · updated 12 November 2026

When would you use @Value and when @ConfigurationProperties? List the differences.

@Value injects one value into one field, and it is the only one of the two that supports SpEL expressions. @ConfigurationProperties binds a whole group of related properties under a prefix to a typed object, with full relaxed binding, validation with @Validated and metadata for IDEs. So we use @Value for one or two isolated values or when we need an expression, and @ConfigurationProperties for anything more.

Why this question is asked

Every Spring Boot application reads configuration, and these two annotations are the two everyday ways to do it. Choosing well matters more than it seems: a service that reads twenty values with scattered @Value annotations is hard to document, hard to validate and easy to break with a typo, while a typed properties class makes the configuration visible in one place. Interviewers ask this to see whether we know the practical differences, not just that both exist. In this answer, we will recap each annotation with an example, then compare them on relaxed binding, validation, metadata and SpEL, and finish with a simple rule for choosing.

1A Quick Recap of @Value

@Value tells Spring to put a value into a field, a constructor parameter or a method parameter when it creates the bean. The value is written as a placeholder, ${...}, that Spring resolves from the Environment, and it can include a default after a colon.

Java
@Service
class ReportService {
@Value("${reports.page-size:50}")
private int pageSize; // 50 unless reports.page-size is set
@Value("${reports.title}")
private String title; // startup fails if reports.title is missing and has no default
}

It is direct and readable for one value. But notice that the property name is a string repeated wherever it is used, there is no single place listing all the keys the service reads, and the conversion and checks are limited to what the field type gives us.

2A Quick Recap of @ConfigurationProperties

@ConfigurationProperties binds all properties under a prefix to an object. Each property becomes a field, nested properties become nested objects, and lists and maps are supported. Spring Boot creates the object as a bean, and other beans inject it like any other dependency.

Java
@ConfigurationProperties("reports")
public record ReportProperties(
@DefaultValue("50") int pageSize,
String title,
@DefaultValue("30s") Duration timeout,
List<String> recipients) {}
// application.yml
// reports:
// page-size: 100
// title: Weekly sales
// recipients: [ops@example.com, sales@example.com]
@Service
class ReportService {
ReportService(ReportProperties props) {
props.pageSize(); // 100
props.timeout(); // PT30S
props.recipients(); // [ops@example.com, sales@example.com]
}
}

The class is registered with @ConfigurationPropertiesScan or @EnableConfigurationProperties. Now all the service's reporting configuration is described by one type, and the compiler checks every use of it.

3Relaxed Binding, Validation and Metadata

Relaxed binding means Spring Boot accepts different spellings of the same property: reports.page-size in YAML, reports.pageSize, or REPORTS_PAGESIZE as an environment variable all bind to the pageSize field. @ConfigurationProperties supports this fully. @Value supports it only partly: it works when we write the placeholder in the canonical form, lower case kebab-case such as ${reports.page-size}, and other forms in the annotation may not match an environment variable.

Validation is the second difference. Adding @Validated to a @ConfigurationProperties class lets us put Bean Validation constraints such as @NotBlank or @Min on the fields, and startup fails with a clear message if a value breaks them. @Value has no equivalent; the best we can do is check in code. The third is metadata: with the spring-boot-configuration-processor dependency, the build generates a description of every property in the class, so IDEs offer completion and documentation for reports.page-size, and tools can list every key a service accepts. @Value properties do not appear there.

@Value compared with @ConfigurationProperties
Feature@Value@ConfigurationProperties
Scopeone value per annotationa group under a prefix
Relaxed bindinglimited: use the kebab-case formfull
Validationnoyes, with @Validated
IDE metadatanoyes, with the configuration processor
SpEL expressionsyes, #{...}no
Lists, maps, nested typesawkwardnatural
Immutable bindingvia constructor parametersrecords or constructor binding

4Where @Value Is the Right Tool: SpEL

@Value has one thing @ConfigurationProperties does not: SpEL, the Spring Expression Language, written as #{...}. It can call methods, refer to other beans and compute values. That is occasionally useful, for example to derive a value from another bean or from a system value.

Java
@Value("#{${reports.page-size:50} * 2}")
private int prefetch; // 100 when page-size is 50
@Value("#{T(java.lang.Runtime).getRuntime().availableProcessors()}")
private int cpus; // 8 on an 8-core machine
@Value("#{'${reports.tags:a,b}'.split(',')}")
private List<String> tags; // [a, b]

So @Value is fine for a single isolated value, a quick expression, or a value used in a test. But expressions in annotations are hard to read and test, so if we find many of them, the logic usually belongs in code or in a properties class instead.

5A Simple Rule for Choosing

The rule I use is this: as soon as a feature reads more than one or two related values, or any value that needs validation or documentation, it gets a @ConfigurationProperties class. @Value stays for the occasional single value, especially in small components or tests, and for the rare case that needs SpEL. In a large codebase this rule also makes reviews easier, because new configuration has an obvious home.

6Follow-up questions

Can I use @ConfigurationProperties on a @Bean method?

Yes. Putting @ConfigurationProperties("pool") on a @Bean method binds properties onto the object the method returns, which is useful for third-party classes we cannot annotate, such as a connection pool configuration object.

Does @Value support relaxed binding at all?

Partly. If the placeholder uses the canonical kebab-case name, such as ${reports.page-size}, Spring Boot can match it against other forms like the environment variable REPORTS_PAGESIZE. If we write ${reports.pageSize} instead, the matching is not guaranteed, so the canonical form is the safe choice.

What happens if a property is missing?

With @Value and no default, startup fails with Could not resolve placeholder. With @ConfigurationProperties, a missing value simply leaves the field null or its default, unless we add a validation constraint such as @NotNull, which then fails startup with a binding message.

7Conclusion

In this answer, we saw that @Value injects single values and supports SpEL expressions, while @ConfigurationProperties binds a group of related properties under a prefix to a typed object. Only @ConfigurationProperties gives full relaxed binding, validation with @Validated and IDE metadata from the configuration processor, so it is the better choice for anything beyond one or two values, with @Value kept for isolated values and expressions.

What to say in the interviewAbout 80 seconds aloud

Open with

I would say @Value is for single values and @ConfigurationProperties is for groups. @Value injects one resolved placeholder into one field or parameter, and it has a default syntax after a colon.

Then, if they want more

It is also the only one of the two that supports SpEL expressions with the hash-brace syntax, so I can compute a value or call another bean. @ConfigurationProperties binds everything under a prefix, say reports, to a typed object, often a record, with nested objects, lists, maps and types like Duration. It gives me three things @Value does not.

Full relaxed binding, so reports.page-size, pageSize and the REPORTS_PAGESIZE environment variable all bind. Validation, by adding @Validated and constraints like @NotBlank or @Min, so bad configuration stops startup with a clear message. And metadata from spring-boot-configuration-processor, so IDEs complete and document the properties and tools can list them.

With @Value, relaxed binding only works reliably if I write the canonical kebab-case name, and there is no validation or metadata. So my rule is that anything beyond one or two related values gets a @ConfigurationProperties class, registered with @ConfigurationPropertiesScan. I keep @Value for an isolated value, a test, or the rare case where I really need an expression.

About this answer

Last updated
12 November 2026
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 Boot reference
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 @Value and when @ConfigurationProperties? List the differences.": https://scrivio-interview-library.netlify.app/spring-boot/externalized-configuration/d3f5ef8c3e/

More in Externalized configuration