2V0-72.22PSE · Question #39
Which statement is true? (Choose the best answer.)
The correct answer is D. @ActiveProfiles is a class-level annotation that is used to declare which bean definition profiles. @ActiveProfiles is a class-level annotation used to declare which bean definition profiles should be active when loading an ApplicationContext for integration tests. For example, @ActiveProfiles("test") tells Spring to activate the "test" profile, enabling only beans annotated…
Question
Which statement is true? (Choose the best answer.)
Options
- A@ActiveProfiles is a class-level annotation that is used to instruct the Spring TestContext
- B@ActiveProfiles is a class-level annotation that you can use to configure how the Spring
- C@ActiveProfiles is a class-level annotation that you can use to configure the locations of
- D@ActiveProfiles is a class-level annotation that is used to declare which bean definition profiles
How the community answered
(48 responses)- A6% (3)
- B2% (1)
- C2% (1)
- D90% (43)
Explanation
@ActiveProfiles is a class-level annotation used to declare which bean definition profiles should be active when loading an ApplicationContext for integration tests. For example, @ActiveProfiles("test") tells Spring to activate the "test" profile, enabling only beans annotated with @Profile("test").
Why the distractors are wrong:
- A is wrong because
@ActiveProfilesdoesn't instruct the Spring TestContext framework itself - it controls profile activation, not framework behavior. - B is a partial truth but vague - "configure how the Spring..." trails off misleadingly toward framework configuration rather than profile selection.
- C is wrong because configuring locations (e.g., XML config file paths) is the job of
@ContextConfiguration, not@ActiveProfiles.
Memory tip: Think of @ActiveProfiles as a filter switch - it switches on specific groups of beans by their profile name. If you need locations → @ContextConfiguration; if you need profiles → @ActiveProfiles.
Topics
Community Discussion
No community discussion yet for this question.