Welcome to ExamTopics
ExamTopics Logo
- Expert Verified, Online, Free.
exam questions

Exam 2V0-72.22 All Questions

View all questions & answers for the 2V0-72.22 exam

Exam 2V0-72.22 topic 1 question 1 discussion

Actual exam question from VMware's 2V0-72.22
Question #: 1
Topic #: 1
[All 2V0-72.22 Questions]

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.
Show Suggested Answer Hide Answer
Suggested Answer: B 🗳️

Comments

Chosen Answer:
This is a voting comment (?) , you can switch to a simple comment.
Switch to a voting comment New
faciorys
Highly Voted 1 year, 11 months ago
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
upvoted 8 times
...
stefumies
Most Recent 3 months, 1 week ago
B is correct and as per Spring documentation
upvoted 1 times
...
Evoila_TrainingMaterial
4 months, 1 week ago
Selected Answer: B
B. Ensure a valid @ComponentScan annotation in the Java configuration is specified. This is the correct answer. The @ComponentScan annotation tells Spring where to look for classes annotated with @Component (and other stereotype annotations like @Service, @Repository, and @Controller). Without this, Spring will not know to scan the specified packages for annotated classes.
upvoted 1 times
...
Examtopics_admin
11 months, 3 weeks ago
Test to be
upvoted 1 times
...
nesreenmhd123
1 year, 1 month ago
B is the correct answer: https://www.baeldung.com/spring-component-annotation
upvoted 2 times
...
Ancient1
1 year, 3 months ago
Selected Answer: B
In order for spring to find the beans, you need to add @ComponentScan
upvoted 1 times
...
zakupower
1 year, 8 months ago
Selected Answer: B
Valid bean name is provided for you using the name of the class, @ComponentScan on a @Configuration marked class is needed.
upvoted 3 times
...
Community vote distribution
A (35%)
C (25%)
B (20%)
Other
Most Voted
A voting comment increases the vote count for the chosen answer by one.

Upvoting a comment with a selected answer will also increase the vote count towards that answer by one. So if you see a comment that you already agree with, you can upvote it instead of posting a new comment.

SaveCancel
Loading ...