Bird
0
0

Which annotation should you use to indicate that a class should be managed as a bean by Spring Boot's IoC container?

easy📝 Conceptual Q2 of 15
Spring Boot - Inversion of Control and Dependency Injection
Which annotation should you use to indicate that a class should be managed as a bean by Spring Boot's IoC container?
A@Entity
B@RequestMapping
C@Component
D@EnableAutoConfiguration
Step-by-Step Solution
Solution:
  1. Step 1: Identify bean registration annotation

    @Component marks a class as a Spring-managed bean.
  2. Step 2: Exclude other annotations

    @RequestMapping is for web endpoints, @Entity for JPA entities, @EnableAutoConfiguration for config.
  3. Final Answer:

    @Component -> Option C
  4. Quick Check:

    @Component registers beans [OK]
Quick Trick: @Component registers a class as a Spring bean [OK]
Common Mistakes:
  • Confusing @Entity with bean registration
  • Using web-related annotations for bean declaration

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Spring Boot Quizzes