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

public Class NoSuchBeanDefinitionException

extends BeansException
Class Inheritance
Known Direct Subclasses
org.springframework.beans.factory.NoUniqueBeanDefinitionException
Annotations
@SuppressWarnings:serial
Imports
org.springframework.beans.BeansException, org.springframework.core.ResolvableType, org.springframework.lang.Nullable

Exception thrown when a BeanFactory is asked for a bean instance for which it cannot find a definition. This may point to a non-existing bean, a non-unique bean, or a manually registered singleton instance without an associated bean definition.
Authors
Rod Johnson, Juergen Hoeller, Stephane Nicoll
See Also
BeanFactory#getBean(String), BeanFactory#getBean(Class), NoUniqueBeanDefinitionException

Field Summary

Modifier and TypeField and Description
private final String
private final ResolvableType

Constructor Summary

AccessConstructor and Description
public
NoSuchBeanDefinitionException(String
the name of the missing bean
name
)

Create a new NoSuchBeanDefinitionException.

public
NoSuchBeanDefinitionException(String
the name of the missing bean
name
,
String
detailed message describing the problem
message
)

Create a new NoSuchBeanDefinitionException.

public
NoSuchBeanDefinitionException(Class<?>
required type of the missing bean
type
)

Create a new NoSuchBeanDefinitionException.

public
NoSuchBeanDefinitionException(Class<?>
required type of the missing bean
type
,
String
detailed message describing the problem
message
)

Create a new NoSuchBeanDefinitionException.

public
NoSuchBeanDefinitionException(ResolvableType
full type declaration of the missing bean
type
)

Create a new NoSuchBeanDefinitionException.

public
NoSuchBeanDefinitionException(ResolvableType
full type declaration of the missing bean
type
,
String
detailed message describing the problem
message
)

Create a new NoSuchBeanDefinitionException.

Method Summary

Modifier and TypeMethod and Description
public String
getBeanName()

Return the name of the missing bean, if it was a lookup by name that failed.

public Class<?>
getBeanType()

Return the required type of the missing bean, if it was a lookup by type that failed.

public int
getNumberOfBeansFound()

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

public ResolvableType
getResolvableType()

Return the required ResolvableType of the missing bean, if it was a lookup by type that failed.

Field Detail

beanNameback to summary
private final String beanName
Annotations
@Nullable
resolvableTypeback to summary
private final ResolvableType resolvableType
Annotations
@Nullable

Constructor Detail

NoSuchBeanDefinitionExceptionback to summary
public NoSuchBeanDefinitionException(String name)

Create a new NoSuchBeanDefinitionException.

Parameters
name:String

the name of the missing bean

NoSuchBeanDefinitionExceptionback to summary
public NoSuchBeanDefinitionException(String name, String message)

Create a new NoSuchBeanDefinitionException.

Parameters
name:String

the name of the missing bean

message:String

detailed message describing the problem

NoSuchBeanDefinitionExceptionback to summary
public NoSuchBeanDefinitionException(Class<?> type)

Create a new NoSuchBeanDefinitionException.

Parameters
type:Class<?>

required type of the missing bean

NoSuchBeanDefinitionExceptionback to summary
public NoSuchBeanDefinitionException(Class<?> type, String message)

Create a new NoSuchBeanDefinitionException.

Parameters
type:Class<?>

required type of the missing bean

message:String

detailed message describing the problem

NoSuchBeanDefinitionExceptionback to summary
public NoSuchBeanDefinitionException(ResolvableType type)

Create a new NoSuchBeanDefinitionException.

Parameters
type:ResolvableType

full type declaration of the missing bean

Since
4.3.4
NoSuchBeanDefinitionExceptionback to summary
public NoSuchBeanDefinitionException(ResolvableType type, String message)

Create a new NoSuchBeanDefinitionException.

Parameters
type:ResolvableType

full type declaration of the missing bean

message:String

detailed message describing the problem

Since
4.3.4

Method Detail

getBeanNameback to summary
public String getBeanName()

Return the name of the missing bean, if it was a lookup by name that failed.

Annotations
@Nullable
getBeanTypeback to summary
public Class<?> getBeanType()

Return the required type of the missing bean, if it was a lookup by type that failed.

Annotations
@Nullable
getNumberOfBeansFoundback to summary
public int getNumberOfBeansFound()

Return the number of beans found when only one matching bean was expected. For a regular NoSuchBeanDefinitionException, this will always be 0.

See Also
NoUniqueBeanDefinitionException
getResolvableTypeback to summary
public ResolvableType getResolvableType()

Return the required ResolvableType of the missing bean, if it was a lookup by type that failed.

Annotations
@Nullable
Since
4.3.4