Bird
0
0

You want to activate the test profile without changing application.properties. Which of these is a valid way to do it when running your Spring Boot app from the command line?

hard📝 Application Q15 of 15
Spring Boot - Application Configuration
You want to activate the test profile without changing application.properties. Which of these is a valid way to do it when running your Spring Boot app from the command line?
Ajava -jar app.jar -profile test
Bjava -jar app.jar -Dspring.profiles.active=test
Cjava -jar app.jar --profile=test
Djava -jar app.jar --spring.profiles.active=test
Step-by-Step Solution
Solution:
  1. Step 1: Recall command line profile activation syntax

    Spring Boot uses --spring.profiles.active=profile to activate profiles via command line arguments.
  2. Step 2: Check each option

    java -jar app.jar --spring.profiles.active=test uses the correct Spring Boot command-line syntax. java -jar app.jar -Dspring.profiles.active=test incorrectly places the -D JVM argument after -jar; correct would be java -Dspring.profiles.active=test -jar app.jar. Flags like -profile test and --profile=test are not supported by Spring Boot.
  3. Final Answer:

    java -jar app.jar --spring.profiles.active=test -> Option D
  4. Quick Check:

    Use --spring.profiles.active=profile on command line [OK]
Quick Trick: Use --spring.profiles.active=profile to activate profiles [OK]
Common Mistakes:
  • Using -profile or --profile flags incorrectly
  • Confusing JVM -D options without proper placement
  • Trying to set profile inside application.properties only

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Spring Boot Quizzes