BeanDefinitionOverrideException class
The error thrown when a bean name or alias is registered while the name is already taken.
Two beans got the same name, usually two classes with the same name in
different folders, or a @Bean method named like a class. Rename one
(@Component('otherName')), or set
DefaultListableBeanFactory.allowBeanDefinitionOverriding when
replacing a bean on purpose. It is a BeanDefinitionStoreException.
// Registering the same name twice.
BeanDefinition<English> english() =>
BeanDefinition<English>(name: 'english', create: (_) => English());
factory.registerBeanDefinition(english());
factory.registerBeanDefinition(english()); // throws
Spring (Java):
factory.setAllowBeanDefinitionOverriding(false);
factory.registerBeanDefinition("english", def);
factory.registerBeanDefinition("english", def); // throws
- Inheritance
-
- Object
- BeansException
- BeanDefinitionStoreException
- BeanDefinitionOverrideException
Constructors
- BeanDefinitionOverrideException(String name, String? source)
-
nameis taken;sourcedescribes the registration that was rejected.
Properties
- cause → Object?
-
The error that caused this one, if any: what a constructor threw, or
the container error of a nested bean.
finalinherited
- hashCode → int
-
The hash code for this object.
no setterinherited
- message → String
-
A human-readable description of the problem.
finalinherited
- mostSpecificCause → Object
-
rootCause, or this exception when it has no cause. Spring:
getMostSpecificCause().no setterinherited - name → String
-
The clashing bean name or alias.
final
- rootCause → Object?
-
The innermost cause: cause followed through nested container
errors, or
nullwithout a cause. Usually the error that really went wrong. Spring:getRootCause().no setterinherited - runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
- source → String?
-
The source of the rejected registration, if known.
final
Methods
-
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
toString(
) → String -
A string representation of this object.
inherited
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited