Class NoSuchBeanDefinitionException

All Implemented Interfaces:
Serializable
Direct Known Subclasses:
NoUniqueBeanDefinitionException

public class NoSuchBeanDefinitionException extends BeansException
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.
Author:
Rod Johnson, Juergen Hoeller, Stephane Nicoll
See Also:
  • Constructor Details

    • NoSuchBeanDefinitionException

      public NoSuchBeanDefinitionException(String name)
      Create a new NoSuchBeanDefinitionException.
      Parameters:
      name - the name of the missing bean
    • NoSuchBeanDefinitionException

      public NoSuchBeanDefinitionException(String name, String message)
      Create a new NoSuchBeanDefinitionException.
      Parameters:
      name - the name of the missing bean
      message - detailed message describing the problem
    • NoSuchBeanDefinitionException

      public NoSuchBeanDefinitionException(Class<?> type)
      Create a new NoSuchBeanDefinitionException.
      Parameters:
      type - required type of the missing bean
    • NoSuchBeanDefinitionException

      public NoSuchBeanDefinitionException(Class<?> type, String message)
      Create a new NoSuchBeanDefinitionException.
      Parameters:
      type - required type of the missing bean
      message - detailed message describing the problem
    • NoSuchBeanDefinitionException

      public NoSuchBeanDefinitionException(ResolvableType type)
      Create a new NoSuchBeanDefinitionException.
      Parameters:
      type - full type declaration of the missing bean
      Since:
      4.3.4
    • NoSuchBeanDefinitionException

      public NoSuchBeanDefinitionException(ResolvableType type, String message)
      Create a new NoSuchBeanDefinitionException.
      Parameters:
      type - full type declaration of the missing bean
      message - detailed message describing the problem
      Since:
      4.3.4
  • Method Details

    • getBeanName

      @Nullable public String getBeanName()
      Return the name of the missing bean, if it was a lookup by name that failed.
    • getBeanType

      @Nullable public Class<?> getBeanType()
      Return the required type of the missing bean, if it was a lookup by type that failed.
    • getResolvableType

      @Nullable public ResolvableType getResolvableType()
      Return the required ResolvableType of the missing bean, if it was a lookup by type that failed.
      Since:
      4.3.4
    • getNumberOfBeansFound

      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: