How will you handle the ambiguities of autowiring in Spring?

How will you handle the ambiguities of autowiring in Spring?

When autowiring using byType or constructor, it\'s possible that the container may find two or more beans whose type matches the property\'s type or the types of the constructor arguments. What will happen if there are  ambiguous beans suitable for autowiring?

Spring can\'t sort out ambiguities and chooses to throw an exception rather than guess which bean you meant to wire in. If you encounter such ambiguities when autowiring, the best solution is not to autowire the bean.

By:Jalees
Date:2031-01-09 00:00:00

Post Your Answers


User Email:

User Name:
Answers:

Related Java Subjective Links

Java Subjective interview questions and answers for experienced and fresher