Exam 2v0-7222 All QuestionsBrowse all questions from this exam
Question 36

Which statement is true about the @PropertySource annotation? (Choose the best answer.)

    Correct Answer: D

    The @PropertySource annotation is used to add a set of name/value pairs to the Spring Environment from an external source. This means it is capable of loading properties from external property files and adding them to the application's environment, which can then be used within the application.

Discussion
nesreenmhd123Option: D

D is correct. https://docs.spring.io/spring-framework/reference/core/beans/environment.html#beans-using-propertysource

Tolo01Option: D

Option A is not correct: @PropertySource is not specifically used to designate the location of the application.properties file in a Spring Boot application. In a Spring Boot application, the application.properties file is automatically loaded from the classpath by default without needing to use @PropertySource. Option B is not entirely accurate: While you can use @PropertySource to load properties from an external property file, it allows you to load multiple key-value pairs rather than just a single property value. Option C is not correct: @PropertySource does not designate the file directory of the application.properties file in a Spring Boot application. Again, in Spring Boot, the application.properties file is automatically loaded from the classpath by default without needing to use @PropertySource.

zakupowerOption: A

None are exactly correct. It is an annotation to be used in tests to specify properties files to be included. Also it overrides the standard application.properties file.

rhuancaOption: D

why not D ? I can not see any problem with D