Class NoUniqueBeanDefinitionException
java.lang.Object
java.lang.Throwable
java.lang.Exception
java.lang.RuntimeException
org.springframework.core.NestedRuntimeException
org.springframework.beans.BeansException
org.springframework.beans.factory.NoSuchBeanDefinitionException
org.springframework.beans.factory.NoUniqueBeanDefinitionException
- All Implemented Interfaces:
- Serializable
Exception thrown when a 
BeanFactory is asked for a bean instance for which
multiple matching candidates have been found when only one matching bean was expected.- Since:
- 3.2.1
- Author:
- Juergen Hoeller, Stephane Nicoll
- See Also:
- 
Constructor SummaryConstructorsConstructorDescriptionNoUniqueBeanDefinitionException(Class<?> type, int numberOfBeansFound, String message) Create a newNoUniqueBeanDefinitionException.NoUniqueBeanDefinitionException(Class<?> type, String... beanNamesFound) Create a newNoUniqueBeanDefinitionException.NoUniqueBeanDefinitionException(Class<?> type, Collection<String> beanNamesFound) Create a newNoUniqueBeanDefinitionException.NoUniqueBeanDefinitionException(Class<?> type, Collection<String> beanNamesFound, String message) Create a newNoUniqueBeanDefinitionException.NoUniqueBeanDefinitionException(ResolvableType type, String... beanNamesFound) Create a newNoUniqueBeanDefinitionException.NoUniqueBeanDefinitionException(ResolvableType type, Collection<String> beanNamesFound) Create a newNoUniqueBeanDefinitionException.
- 
Method SummaryModifier and TypeMethodDescriptionReturn the names of all beans found when only one matching bean was expected.intReturn the number of beans found when only one matching bean was expected.Methods inherited from class NoSuchBeanDefinitionExceptiongetBeanName, getBeanType, getResolvableTypeMethods inherited from class NestedRuntimeExceptioncontains, getMostSpecificCause, getRootCauseMethods inherited from class ThrowableaddSuppressed, fillInStackTrace, getCause, getLocalizedMessage, getMessage, getStackTrace, getSuppressed, initCause, printStackTrace, printStackTrace, printStackTrace, setStackTrace, toString
- 
Constructor Details- 
NoUniqueBeanDefinitionExceptionpublic NoUniqueBeanDefinitionException(Class<?> type, Collection<String> beanNamesFound, String message) Create a newNoUniqueBeanDefinitionException.- Parameters:
- type- required type of the non-unique bean
- beanNamesFound- the names of all matching beans (as a Collection)
- message- detailed message describing the problem
- Since:
- 6.2
 
- 
NoUniqueBeanDefinitionException
- 
NoUniqueBeanDefinitionExceptionCreate a newNoUniqueBeanDefinitionException.- Parameters:
- type- required type of the non-unique bean
- beanNamesFound- the names of all matching beans (as a Collection)
 
- 
NoUniqueBeanDefinitionException
- 
NoUniqueBeanDefinitionExceptionCreate a newNoUniqueBeanDefinitionException.- Parameters:
- type- required type of the non-unique bean
- beanNamesFound- the names of all matching beans (as a Collection)
- Since:
- 5.1
 
- 
NoUniqueBeanDefinitionExceptionCreate a newNoUniqueBeanDefinitionException.- Parameters:
- type- required type of the non-unique bean
- beanNamesFound- the names of all matching beans (as an array)
- Since:
- 5.1
 
 
- 
- 
Method Details- 
getNumberOfBeansFoundpublic int getNumberOfBeansFound()Return the number of beans found when only one matching bean was expected. For a NoUniqueBeanDefinitionException, this will usually be higher than 1.- Overrides:
- getNumberOfBeansFoundin class- NoSuchBeanDefinitionException
- See Also:
 
- 
getBeanNamesFoundReturn the names of all beans found when only one matching bean was expected. Note that this may benullif not specified at construction time.- Since:
- 4.3
- See Also:
 
 
-