hiexam
vmware · 2V0-7222 · Q602 · multiple_choice · topic_1

If a class is annotated with @Component, what should be done to have Spring automatically detect the annotated class an…

If a class is annotated with @Component, what should be done to have Spring automatically detect the annotated class and load it as a bean? (Choose the best answer.)
  • A.Ensure a valid bean name in the @Component annotation is specified.
  • B.Ensure a valid @ComponentScan annotation in the Java configuration is specified.
  • C.Ensure a valid @Scope for the class is specified.
  • D.Ensure a valid @Bean for the class is specified.
Explanation
Selected Answer: B To autodetect these classes and register the corresponding beans, you need to add @ComponentScan to your @Configuration class https://docs.spring.io/spring-framework/docs/current/reference/html/core.html#spring-core

Reference: examtopics_top_comment

Practice with progress tracking

Sign in to track wrong answers, get spaced-repetition reminders, and run timed exam mode.