Bird
0
0

You have a class annotated with @ConfigurationProperties(prefix = "app") but after running the app, the properties are not injected. What is the most likely cause?

medium📝 Debug Q6 of 15
Spring Boot - Application Configuration
You have a class annotated with @ConfigurationProperties(prefix = "app") but after running the app, the properties are not injected. What is the most likely cause?
AThe class has no default constructor
BThe prefix in properties file is misspelled
CThe class is not registered as a Spring bean
DThe properties file is missing
Step-by-Step Solution
Solution:
  1. Step 1: Check bean registration requirement

    Classes annotated with @ConfigurationProperties must be registered as Spring beans to enable binding.
  2. Step 2: Understand other causes

    While misspelled prefix or missing file can cause issues, the most common cause is missing bean registration.
  3. Final Answer:

    The class is not registered as a Spring bean -> Option C
  4. Quick Check:

    Bean registration required for binding [OK]
Quick Trick: Register @ConfigurationProperties class as a bean [OK]
Common Mistakes:
  • Ignoring bean registration
  • Assuming default constructor is mandatory
  • Overlooking prefix spelling

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Spring Boot Quizzes