Bird
0
0

Which annotation is used to activate a specific profile in a Spring Boot test class?

easy📝 Conceptual Q2 of 15
Spring Boot - Testing Spring Boot Applications
Which annotation is used to activate a specific profile in a Spring Boot test class?
A@Profile
B@ActiveProfiles
C@TestProfile
D@EnableProfile
Step-by-Step Solution
Solution:
  1. Step 1: Recall the annotation for activating profiles in tests

    The annotation @ActiveProfiles is designed to specify which profile(s) to activate during testing.
  2. Step 2: Differentiate from other annotations

    @Profile is for beans, @TestProfile and @EnableProfile do not exist in Spring Boot.
  3. Final Answer:

    @ActiveProfiles -> Option B
  4. Quick Check:

    Activate test profile annotation [OK]
Quick Trick: Use @ActiveProfiles to set test environment profile [OK]
Common Mistakes:
  • Confusing @Profile with @ActiveProfiles
  • Using non-existent annotations
  • Trying to activate profiles without annotations

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Spring Boot Quizzes