Which two options will inject the value of the daily.limit system property? (Choose two.)
Which two options will inject the value of the daily.limit system property? (Choose two.)
To inject the value of a system property in Spring, you can use Spring Expression Language (SpEL) syntax. The correct options are #{systemProperties['daily.limit']} and #{systemProperties.daily.limit} as these correctly refer to the system properties. Option D uses #{systemProperties['daily.limit']} which is a correct form and Option E uses #{systemProperties.daily.limit} which is a more simplified but valid form. Other syntaxes like $(...) or #{} without properly referencing systemProperties are not valid for this purpose.
A. @Value(“#{daily.limit}”) E. @Value(“#{systemProperties.daily.limit}”) because we are talking about SystemProperty
Only D is the correct answer
I also realized this now. The way the question is formulated, B and C, has () and not {}. Only D will work. If the () in B and C were changed to {}, then C and D will be correct.
The C is not for systemproperties but only for application properties. In the exam the "(" are replaced by "{". Correct answers are DE
This question appeared on my exam. There is an error on the answers. Answer C is different than in the exam. The text in the exam is @Value(“${daily.limit}”).
Answer is CD
I tested all scenarios on my own IDE and it confirms your answer that it is C and D.
Correct Choices: Option C: @Value("${daily.limit}") Option D: @Value("#{systemProperties['daily.limit']}") These two options correctly inject the value of the daily.limit system property. Incorrect Choices Explanation: Option A: @Value("#{daily.limit}") This syntax is incorrect because it looks for a bean named daily.limit in the Spring context, not a system property. Option B: @Value("$(systemProperties.daily.limit)") This is incorrect because the $(...) syntax is not valid in Spring's @Value annotation. Option E: @Value("#{systemProperties.daily.limit}") This is incorrect because the correct SpEL syntax requires the use of ['...'] for accessing properties dynamically.
Correct Choices: Option C: @Value("${daily.limit}") Option D: @Value("#{systemProperties['daily.limit']}") These two options correctly inject the value of the daily.limit system property. Incorrect Choices Explanation: Option A: @Value("#{daily.limit}") This syntax is incorrect because it looks for a bean named daily.limit in the Spring context, not a system property. Option B: @Value("$(systemProperties.daily.limit)") This is incorrect because the $(...) syntax is not valid in Spring's @Value annotation. Option E: @Value("#{systemProperties.daily.limit}") This is incorrect because the correct SpEL syntax requires the use of ['...'] for accessing properties dynamically.
Probably, the question is incorrect. Correct way of Spring Express language like this https://docs.spring.io/spring-framework/docs/3.0.x/reference/expressions.html value="#{ systemProperties['user.region'] }" and/or value="#{ numberGuess.randomNumber }" and/or @Value("#{ systemProperties['user.region'] }") private String defaultLocale;
The C is not for systemproperties but only for application properties. In the exam the "(" are replaced by "{". Correct answers are BD