nerdexam
Broadcom-VMware

2V0-72.22PSE · Question #99

Which two statements are correct regarding the differences between @ConfigurationProperties and @Value? (Choose two.)

The correct answer is C. @ConfigurationProperties is preferable over @Value when type-safety during property binding is E. @ConfigurationProperties supports relaxed binding of properties, but not property binding through. C is correct because @ConfigurationProperties binds an entire group of properties to a typed POJO, giving you compile-time type safety, validation support (@Validated), and IDE auto-completion - making it the preferred choice over @Value when working with structured…

Core Spring

Question

Which two statements are correct regarding the differences between @ConfigurationProperties and @Value? (Choose two.)

Options

  • A@Value must be used for environment variables, as @ConfigurationProperties cannot access the
  • B@Value supports relaxed binding of properties, but not property binding through SpEL.
  • C@ConfigurationProperties is preferable over @Value when type-safety during property binding is
  • D@ConfigurationProperties only bind properties from .properties files, not from .yml files.
  • E@ConfigurationProperties supports relaxed binding of properties, but not property binding through

How the community answered

(40 responses)
  • A
    10% (4)
  • B
    5% (2)
  • C
    83% (33)
  • D
    3% (1)

Explanation

C is correct because @ConfigurationProperties binds an entire group of properties to a typed POJO, giving you compile-time type safety, validation support (@Validated), and IDE auto-completion - making it the preferred choice over @Value when working with structured configuration.

E is correct because @ConfigurationProperties supports relaxed binding (e.g., my.prop, MY_PROP, my-prop, and myProp all map to the same field), but it does not support SpEL expressions. @Value is the opposite - it supports SpEL (e.g., @Value("#{systemProperties['user.home']}")) but does not support relaxed binding.

Why the distractors are wrong:

  • A: @ConfigurationProperties can access environment variables - both annotations read from the same Environment abstraction.
  • B: This has the capabilities backwards - relaxed binding belongs to @ConfigurationProperties, and SpEL belongs to @Value.
  • D: @ConfigurationProperties works with both .properties and .yml files; it is not limited to one format.

Memory tip: Think of the split as "Config = Class" vs "Value = Variable" - @ConfigurationProperties binds a class (type-safe, relaxed), while @Value injects a single variable (SpEL-capable, strict). Their SpEL/relaxed-binding capabilities are mutually exclusive and swapped.

Topics

#Configuration properties#Type-safe binding#Relaxed binding#SpEL support

Community Discussion

No community discussion yet for this question.

Full 2V0-72.22PSE Practice