Spring Boot - Spring AnnotationsWhich of these is a valid way to activate a Spring profile named 'dev' when running the application?AAdd @EnableProfile("dev") annotation to the main classBSet the JVM argument: -Dspring.profiles.active=devCUse @Profile("dev") on the main application classDSet environment variable SPRING_PROFILE=devCheck Answer
Step-by-Step SolutionSolution:Step 1: Identify how to activate profilesSpring Boot activates profiles via the property spring.profiles.active, which can be set as a JVM argument.Step 2: Evaluate other options@EnableProfile does not exist, @Profile is for beans, and SPRING_PROFILE is not the correct env variable name.Final Answer:Set the JVM argument: -Dspring.profiles.active=dev -> Option BQuick Check:Activate profile = -Dspring.profiles.active=dev [OK]Quick Trick: Use -Dspring.profiles.active=profileName to activate profiles [OK]Common Mistakes:Using @EnableProfile which is invalidConfusing @Profile usage with activationSetting wrong environment variable name
Master "Spring Annotations" in Spring Boot9 interactive learning modes - each teaches the same concept differentlyLearnWhyDeepVisualTryChallengeProjectRecallPerf
More Spring Boot Quizzes Application Configuration - Environment variables in configuration - Quiz 7medium Exception Handling - ResponseEntityExceptionHandler - Quiz 9hard Logging - SLF4J and Logback basics - Quiz 8hard Logging - Package-level log configuration - Quiz 7medium REST Controllers - @GetMapping for GET requests - Quiz 9hard Request and Response Handling - Request mapping by method and path - Quiz 10hard Spring Annotations - @Value for property injection - Quiz 7medium Spring Annotations - @SpringBootApplication breakdown - Quiz 2easy Spring Annotations - @Scope for bean scope - Quiz 1easy Spring Boot Fundamentals - Project structure walkthrough - Quiz 7medium