2v0-7222 Exam QuestionsBrowse all questions from this exam

2v0-7222 Exam - Question 70


Which two mechanisms of autowiring a dependency when multiple beans match the dependency's type are correct? (Choose two.)

Show Answer
Correct Answer: AD

Use of @Qualifier annotation on the class and @Autowired annotation either on a field or setter methods allows for clear specification of which bean should be injected when multiple beans of the same type are available. Additionally, using @Qualifier and @Autowired annotations together on a field can also specify the injection of the correct bean. These approaches ensure precision and reduce ambiguity in dependency injection.

Discussion

2 comments
Sign in to comment
GlothanOptions: AD
Dec 20, 2023

Option A is correct. You can use the @Qualifier annotation along with @Autowired either on a field or setter methods to specify which bean should be injected when multiple beans of the same type are available. Option B is incorrect. Using @Qualifier and @Autowired together with setter methods is not a common or recommended practice.

2211094Options: AB
Jul 5, 2024

AB is correct