Top Description Fields Constructors Methods
org.springframework.beans.factory

public Class NoUniqueBeanDefinitionException

extends NoSuchBeanDefinitionException
Class Inheritance
Annotations
@SuppressWarnings:serial
Imports
java.util.ArrayList, .Arrays, .Collection, org.springframework.core.ResolvableType, org.springframework.lang.Nullable, org.springframework.util.StringUtils

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.
Author
Juergen Hoeller
Since
3.2.1
See Also
BeanFactory#getBean(Class)

Field Summary

Modifier and TypeField and Description
private final Collection<String>
private final int

Constructor Summary

AccessConstructor and Description
public
NoUniqueBeanDefinitionException(Class<?>
required type of the non-unique bean
type
,
int
the number of matching beans
numberOfBeansFound
,
String
detailed message describing the problem
message
)

Create a new NoUniqueBeanDefinitionException.

public
NoUniqueBeanDefinitionException(Class<?>
required type of the non-unique bean
type
,
Collection<String>
the names of all matching beans (as a Collection)
beanNamesFound
)

Create a new NoUniqueBeanDefinitionException.

public
NoUniqueBeanDefinitionException(Class<?>
required type of the non-unique bean
type
,
String...
the names of all matching beans (as an array)
beanNamesFound
)

Create a new NoUniqueBeanDefinitionException.

public
NoUniqueBeanDefinitionException(ResolvableType
required type of the non-unique bean
type
,
Collection<String>
the names of all matching beans (as a Collection)
beanNamesFound
)

Create a new NoUniqueBeanDefinitionException.

public
NoUniqueBeanDefinitionException(ResolvableType
required type of the non-unique bean
type
,
String...
the names of all matching beans (as an array)
beanNamesFound
)

Create a new NoUniqueBeanDefinitionException.

Method Summary

Modifier and TypeMethod and Description
public Collection<String>
getBeanNamesFound()

Return the names of all beans found when only one matching bean was expected.

public int
getNumberOfBeansFound()

Overrides org.springframework.beans.factory.NoSuchBeanDefinitionException.getNumberOfBeansFound.

Return the number of beans found when only one matching bean was expected.
Inherited from org.springframework.beans.factory.NoSuchBeanDefinitionException:
getBeanNamegetBeanTypegetResolvableType

Field Detail

beanNamesFoundback to summary
private final Collection<String> beanNamesFound
Annotations
@Nullable
numberOfBeansFoundback to summary
private final int numberOfBeansFound

Constructor Detail

NoUniqueBeanDefinitionExceptionback to summary
public NoUniqueBeanDefinitionException(Class<?> type, int numberOfBeansFound, String message)

Create a new NoUniqueBeanDefinitionException.

Parameters
type:Class<?>

required type of the non-unique bean

numberOfBeansFound:int

the number of matching beans

message:String

detailed message describing the problem

NoUniqueBeanDefinitionExceptionback to summary
public NoUniqueBeanDefinitionException(Class<?> type, Collection<String> beanNamesFound)

Create a new NoUniqueBeanDefinitionException.

Parameters
type:Class<?>

required type of the non-unique bean

beanNamesFound:Collection<String>

the names of all matching beans (as a Collection)

NoUniqueBeanDefinitionExceptionback to summary
public NoUniqueBeanDefinitionException(Class<?> type, String... beanNamesFound)

Create a new NoUniqueBeanDefinitionException.

Parameters
type:Class<?>

required type of the non-unique bean

beanNamesFound:String[]

the names of all matching beans (as an array)

NoUniqueBeanDefinitionExceptionback to summary
public NoUniqueBeanDefinitionException(ResolvableType type, Collection<String> beanNamesFound)

Create a new NoUniqueBeanDefinitionException.

Parameters
type:ResolvableType

required type of the non-unique bean

beanNamesFound:Collection<String>

the names of all matching beans (as a Collection)

Since
5.1
NoUniqueBeanDefinitionExceptionback to summary
public NoUniqueBeanDefinitionException(ResolvableType type, String... beanNamesFound)

Create a new NoUniqueBeanDefinitionException.

Parameters
type:ResolvableType

required type of the non-unique bean

beanNamesFound:String[]

the names of all matching beans (as an array)

Since
5.1

Method Detail

getBeanNamesFoundback to summary
public Collection<String> getBeanNamesFound()

Return the names of all beans found when only one matching bean was expected. Note that this may be null if not specified at construction time.

Annotations
@Nullable
Since
4.3
See Also
getBeanType()
getNumberOfBeansFoundback to summary
public int getNumberOfBeansFound()

Overrides org.springframework.beans.factory.NoSuchBeanDefinitionException.getNumberOfBeansFound.

Return the number of beans found when only one matching bean was expected. For a NoUniqueBeanDefinitionException, this will usually be higher than 1.

Annotations
@Override
See Also
getBeanType()