László Váradi opened SPR-9682 and commented
The ConfigurationClassBeanDefinitionReader.loadBeanDefinitionsForModelMethod contains the following:
// has this already been overridden (e.g. via XML)?
if (this.registry.containsBeanDefinition(beanName)) {
BeanDefinition existingBeanDef = registry.getBeanDefinition(beanName);
// is the existing bean definition one that was created from a configuration class?
if (!(existingBeanDef instanceof ConfigurationClassBeanDefinition)) {
// no -> then it's an external override, probably XML
// overriding is legal, return immediately
if (logger.isDebugEnabled()) {
logger.debug(String.format("Skipping loading bean definition for %s: a definition for bean " +
"'%s' already exists. This is likely due to an override in XML.", beanMethod, beanName));
}
return;
}
}
But it is not true ("overriding is legal") if the application context (AbstractRefreshableApplicationContext) is set to disallow it by setAllowBeanDefinitionOverriding(true).
I think the bean definition should be registered, and let the application context decide whether the override is legal or not. And if it is legal, which bean should be active?
In our case, classpath scanning have found the bean, and the bean definition in a @Configuration class with the same name (but with more specific configuration) was not created, causing some problem.
Affects: 3.1.2
Issue Links:
6 votes, 12 watchers
László Váradi opened SPR-9682 and commented
The ConfigurationClassBeanDefinitionReader.loadBeanDefinitionsForModelMethod contains the following:
But it is not true ("overriding is legal") if the application context (AbstractRefreshableApplicationContext) is set to disallow it by setAllowBeanDefinitionOverriding(true).
I think the bean definition should be registered, and let the application context decide whether the override is legal or not. And if it is legal, which bean should be active?
In our case, classpath scanning have found the bean, and the bean definition in a
@Configurationclass with the same name (but with more specific configuration) was not created, causing some problem.Affects: 3.1.2
Issue Links:
@Primaryto override@ComponentScan-edbeans@ComponentScanare skipped in@Configurationoverride6 votes, 12 watchers