Explicit error message for bean name clash with containing configuration class
Issue: SPR-15775
This commit is contained in:
@@ -198,6 +198,11 @@ class ConfigurationClassBeanDefinitionReader {
|
||||
|
||||
// Has this effectively been overridden before (e.g. via XML)?
|
||||
if (isOverriddenByExistingDefinition(beanMethod, beanName)) {
|
||||
if (beanName.equals(beanMethod.getConfigurationClass().getBeanName())) {
|
||||
throw new BeanDefinitionStoreException(beanMethod.getConfigurationClass().getResource().getDescription(),
|
||||
beanName, "Bean name derived from @Bean method '" + beanMethod.getMetadata().getMethodName() +
|
||||
"' clashes with bean name for containing configuration class; please make those names unique!");
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user