nerdexam
Broadcom-VMware

2V0-72.22PSE · Question #44

Which two options will inject the value of the daily.limit system property? (Choose two.)

The correct answer is C. @Value("$(daily.limit)") D. @Value("#{systemProperties['daily.limit']}"). Options C and D are correct because Spring's @Value supports two distinct injection syntaxes: property placeholder ${...} and Spring Expression Language (SpEL) #{...}. Option C (${daily.limit}) uses property placeholder syntax, which directly resolves system properties by their…

Core Spring

Question

Which two options will inject the value of the daily.limit system property? (Choose two.)

Options

  • A@Value("#{daily.limit}")
  • B@Value("$(systemProperties.daily.limit)")
  • C@Value("$(daily.limit)")
  • D@Value("#{systemProperties['daily.limit']}")
  • E@Value("#{systemProperties.daily.limit}")

How the community answered

(30 responses)
  • A
    3% (1)
  • B
    13% (4)
  • C
    80% (24)
  • E
    3% (1)

Explanation

Options C and D are correct because Spring's @Value supports two distinct injection syntaxes: property placeholder ${...} and Spring Expression Language (SpEL) #{...}. Option C (${daily.limit}) uses property placeholder syntax, which directly resolves system properties by their key name. Option D (#{systemProperties['daily.limit']}) uses SpEL to access the implicit systemProperties map with bracket notation, which is required because the key contains a dot character.

Why the distractors fail:

  • A (#{daily.limit}) - SpEL tries to evaluate daily as an object and .limit as a property on it; there is no such bean, so it fails.
  • B (${systemProperties.daily.limit}) - Property placeholder syntax doesn't support navigating objects with dot notation; ${...} treats the entire string as a flat key lookup.
  • E (#{systemProperties.daily.limit}) - SpEL dot notation calls getDaily() on the systemProperties map, then getLimit() on the result. Since the actual key is "daily.limit" (a single string with a dot in it), dot-notation navigation breaks; bracket notation ['daily.limit'] is required.

Memory tip: When the property key contains a dot (like daily.limit), bracket notation ['daily.limit'] is your only safe SpEL option - dots in SpEL mean "navigate into an object," not "part of a key name." And ${} vs #{} = property placeholder vs SpEL - a dollar sign fetches a flat key, a hash evaluates an expression.

Topics

#@Value annotation#Property placeholders#SpEL syntax#System properties

Community Discussion

No community discussion yet for this question.

Full 2V0-72.22PSE Practice