Package org.springframework.beans.factory.support

# Class BeanDefinitionOverrideException

java.lang.Object
java.lang.Throwable
java.lang.Exception
java.lang.RuntimeException
org.springframework.core.NestedRuntimeException
org.springframework.beans.BeansException
org.springframework.beans.FatalBeanException
org.springframework.beans.factory.BeanDefinitionStoreException
org.springframework.beans.factory.support.BeanDefinitionOverrideException

All Implemented Interfaces:
  `Serializable`

public class BeanDefinitionOverrideException extends BeanDefinitionStoreException
Subclass of `BeanDefinitionStoreException` indicating an invalid override attempt: typically registering a new definition for the same bean name while `DefaultListableBeanFactory.isAllowBeanDefinitionOverriding()` is `false`.

Since:
  5.1
Author:
  Juergen Hoeller
See Also:
  - `DefaultListableBeanFactory.setAllowBeanDefinitionOverriding(boolean)`
  - `DefaultListableBeanFactory.registerBeanDefinition(java.lang.String, org.springframework.beans.factory.config.BeanDefinition)`
  - Serialized Form

## Constructor Summary

Constructors
Constructor
Description
`BeanDefinitionOverrideException(String beanName, BeanDefinition beanDefinition, BeanDefinition existingDefinition)`
Create a new BeanDefinitionOverrideException for the given new and existing definition.
`BeanDefinitionOverrideException(String beanName, BeanDefinition beanDefinition, BeanDefinition existingDefinition, String msg)`
Create a new BeanDefinitionOverrideException for the given new and existing definition.

## Method Summary

Modifier and Type
Method
Description
`BeanDefinition`
`getBeanDefinition()`
Return the newly registered bean definition.
`String`
`getBeanName()`
Return the name of the bean.
`BeanDefinition`
`getExistingDefinition()`
Return the existing bean definition for the same name.
`String`
`getResourceDescription()`
Return the description of the resource that the bean definition came from.

### Methods inherited from class org.springframework.core.NestedRuntimeException

`contains, getMostSpecificCause, getRootCause`

### Methods inherited from class java.lang.Throwable

`addSuppressed, fillInStackTrace, getCause, getLocalizedMessage, getMessage, getStackTrace, getSuppressed, initCause, printStackTrace, printStackTrace, printStackTrace, setStackTrace, toString`

### Methods inherited from class java.lang.Object

`clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait`

## Constructor Details

### BeanDefinitionOverrideException

public BeanDefinitionOverrideException(String beanName, BeanDefinition beanDefinition, BeanDefinition existingDefinition)
Create a new BeanDefinitionOverrideException for the given new and existing definition.

Parameters:
  `beanName` - the name of the bean
  `beanDefinition` - the newly registered bean definition
  `existingDefinition` - the existing bean definition for the same name

### BeanDefinitionOverrideException

public BeanDefinitionOverrideException(String beanName, BeanDefinition beanDefinition, BeanDefinition existingDefinition, String msg)
Create a new BeanDefinitionOverrideException for the given new and existing definition.

Parameters:
  `beanName` - the name of the bean
  `beanDefinition` - the newly registered bean definition
  `existingDefinition` - the existing bean definition for the same name
  `msg` - the detail message to include
Since:
  6.2.1

## Method Details

### getResourceDescription

@NonNull public String getResourceDescription()
Return the description of the resource that the bean definition came from.

Overrides:
  `getResourceDescription` in class `BeanDefinitionStoreException`

### getBeanName

@NonNull public String getBeanName()
Return the name of the bean.

Overrides:
  `getBeanName` in class `BeanDefinitionStoreException`

### getBeanDefinition

public BeanDefinition getBeanDefinition()
Return the newly registered bean definition.

See Also:
  - `getBeanName()`

### getExistingDefinition

public BeanDefinition getExistingDefinition()
Return the existing bean definition for the same name.

See Also:
  - `getBeanName()`