类 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
- 所有已实现的接口:
Serializable
public class NoUniqueBeanDefinitionException extends NoSuchBeanDefinitionException
Exception thrown when aBeanFactory
is asked for a bean instance for which multiple matching candidates have been found when only one matching bean was expected.- 从以下版本开始:
- 3.2.1
- 作者:
- Juergen Hoeller
- 另请参阅:
BeanFactory.getBean(Class)
, 序列化表格
构造器概要
构造器 构造器 说明 NoUniqueBeanDefinitionException(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(ResolvableType type, String... beanNamesFound)
Create a newNoUniqueBeanDefinitionException
.NoUniqueBeanDefinitionException(ResolvableType type, Collection<String> beanNamesFound)
Create a newNoUniqueBeanDefinitionException
.
方法概要
所有方法 实例方法 具体方法 修饰符和类型 方法 说明 Collection<String>
getBeanNamesFound()
Return the names of all beans found when only one matching bean was expected.int
getNumberOfBeansFound()
Return the number of beans found when only one matching bean was expected.从类继承的方法 org.springframework.beans.factory.NoSuchBeanDefinitionException
getBeanName, getBeanType, getResolvableType
从类继承的方法 org.springframework.core.NestedRuntimeException
contains, getMessage, getMostSpecificCause, getRootCause
构造器详细资料
NoUniqueBeanDefinitionException
public NoUniqueBeanDefinitionException(Class<?> type, int numberOfBeansFound, String message)
Create a newNoUniqueBeanDefinitionException
.- 参数:
type
- required type of the non-unique beannumberOfBeansFound
- the number of matching beansmessage
- detailed message describing the problem
NoUniqueBeanDefinitionException
public NoUniqueBeanDefinitionException(Class<?> type, Collection<String> beanNamesFound)
Create a newNoUniqueBeanDefinitionException
.- 参数:
type
- required type of the non-unique beanbeanNamesFound
- the names of all matching beans (as a Collection)
NoUniqueBeanDefinitionException
public NoUniqueBeanDefinitionException(Class<?> type, String... beanNamesFound)
Create a newNoUniqueBeanDefinitionException
.- 参数:
type
- required type of the non-unique beanbeanNamesFound
- the names of all matching beans (as an array)
NoUniqueBeanDefinitionException
public NoUniqueBeanDefinitionException(ResolvableType type, Collection<String> beanNamesFound)
Create a newNoUniqueBeanDefinitionException
.- 参数:
type
- required type of the non-unique beanbeanNamesFound
- the names of all matching beans (as a Collection)- 从以下版本开始:
- 5.1
NoUniqueBeanDefinitionException
public NoUniqueBeanDefinitionException(ResolvableType type, String... beanNamesFound)
Create a newNoUniqueBeanDefinitionException
.- 参数:
type
- required type of the non-unique beanbeanNamesFound
- the names of all matching beans (as an array)- 从以下版本开始:
- 5.1
方法详细资料
getNumberOfBeansFound
public 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.
getBeanNamesFound
@Nullable public Collection<String> getBeanNamesFound()
Return the names of all beans found when only one matching bean was expected. Note that this may benull
if not specified at construction time.- 从以下版本开始:
- 4.3
- 另请参阅:
NoSuchBeanDefinitionException.getBeanType()