Bird
0
0

Why is it recommended to use @Service and @Repository annotations instead of just @Component in a Spring Boot application?

hard📝 Conceptual Q10 of 15
Spring Boot - Spring Annotations
Why is it recommended to use @Service and @Repository annotations instead of just @Component in a Spring Boot application?
AThey provide additional semantic meaning and enable specific features like exception translation
BThey make the application run faster
CThey automatically generate REST endpoints
DThey are required for Spring Boot to start
Step-by-Step Solution
Solution:
  1. Step 1: Understand semantic annotations

    @Service and @Repository add meaning to the code, clarifying roles.
  2. Step 2: Recognize special features

    @Repository enables exception translation; @Service clarifies business logic layer.
  3. Final Answer:

    They provide additional semantic meaning and enable specific features like exception translation -> Option A
  4. Quick Check:

    Semantic meaning + features = use @Service/@Repository [OK]
Quick Trick: Use specific stereotypes for clarity and extra Spring features [OK]
Common Mistakes:
  • Thinking they improve performance
  • Expecting automatic REST generation
  • Believing they are mandatory for startup

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Spring Boot Quizzes