Bird
0
0

Which of the following is the correct way to enable @ConfigurationProperties support in a Spring Boot application?

easy📝 Syntax Q12 of 15
Spring Boot - Application Configuration
Which of the following is the correct way to enable @ConfigurationProperties support in a Spring Boot application?
AAdd <code>@SpringBootApplication</code> on the properties class
BAdd <code>@EnableConfigurationProperties</code> on a configuration class or main class
CAdd <code>@RestController</code> on the properties class
DAdd <code>@ComponentScan</code> on the properties class
Step-by-Step Solution
Solution:
  1. Step 1: Identify how to activate configuration properties

    Spring Boot requires @EnableConfigurationProperties on a configuration or main class to enable binding of @ConfigurationProperties classes.
  2. Step 2: Review other annotations

    @ComponentScan scans components but does not enable properties binding. @RestController is for web controllers. @SpringBootApplication is for main app class but does not alone enable properties binding.
  3. Final Answer:

    Add @EnableConfigurationProperties on a configuration class or main class -> Option B
  4. Quick Check:

    Enable config properties = D [OK]
Quick Trick: Use @EnableConfigurationProperties to activate property binding [OK]
Common Mistakes:
  • Confusing @ComponentScan with enabling properties
  • Adding @RestController on properties class
  • Assuming @SpringBootApplication alone enables properties

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Spring Boot Quizzes