Bird
0
0

Which combination correctly activates this profile and overrides the default settings?

hard📝 lifecycle Q15 of 15
Spring Boot - Testing Spring Boot Applications
You want to run integration tests with a profile integration that uses a different database URL and disables security. Which combination correctly activates this profile and overrides the default settings?
ACreate <code>application-integration.properties</code> with overrides and annotate tests with <code>@ActiveProfiles("integration")</code>
BAdd <code>spring.profiles.active=integration</code> only in <code>application.properties</code>
CUse <code>@Profile("integration")</code> on the test class without any properties file
DSet environment variable <code>SPRING_PROFILE=integration</code> but keep default properties unchanged
Step-by-Step Solution
Solution:
  1. Step 1: Use profile-specific properties file

    Create application-integration.properties to override database URL and security settings for the integration profile.
  2. Step 2: Activate profile in tests

    Annotate tests with @ActiveProfiles("integration") to activate the profile during test runs.
  3. Final Answer:

    Create application-integration.properties with overrides and annotate tests with @ActiveProfiles("integration") -> Option A
  4. Quick Check:

    Profile file + @ActiveProfiles activates test config [OK]
Quick Trick: Use profile file plus @ActiveProfiles to activate [OK]
Common Mistakes:
  • Setting active profile only in default properties
  • Using @Profile instead of @ActiveProfiles on tests
  • Relying on environment variable without config changes

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Spring Boot Quizzes