Bird
0
0

In Spring Boot, what is the primary function of the @Value annotation?

easy📝 Conceptual Q1 of 15
Spring Boot - Spring Annotations
In Spring Boot, what is the primary function of the @Value annotation?
AMark a class as a Spring component
BDefine a new bean in the application context
CInject values from property files or environment variables into fields
DConfigure database connection settings
Step-by-Step Solution
Solution:
  1. Step 1: Understand @Value usage

    The @Value annotation is used to inject values from external sources like property files or environment variables into Spring-managed beans.
  2. Step 2: Differentiate from other annotations

    It does not define beans (@Bean), mark components (@Component), or configure databases directly.
  3. Final Answer:

    Inject values from property files or environment variables into fields -> Option C
  4. Quick Check:

    @Value injects external values [OK]
Quick Trick: Inject properties into fields with @Value [OK]
Common Mistakes:
  • Confusing @Value with @Component or @Bean
  • Assuming @Value creates beans
  • Thinking @Value configures databases

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Spring Boot Quizzes