Reject multiple primary candidates in ancestor factory as well

Closes gh-26612
This commit is contained in:
Juergen Hoeller
2024-02-20 16:24:03 +01:00
parent ad2e95be4b
commit 889c4e0ff5
2 changed files with 34 additions and 4 deletions

View File

@@ -1805,7 +1805,7 @@ public class DefaultListableBeanFactory extends AbstractAutowireCapableBeanFacto
if (primaryBeanName != null) {
boolean candidateLocal = containsBeanDefinition(candidateBeanName);
boolean primaryLocal = containsBeanDefinition(primaryBeanName);
if (candidateLocal && primaryLocal) {
if (candidateLocal == primaryLocal) {
throw new NoUniqueBeanDefinitionException(requiredType, candidates.size(),
"more than one 'primary' bean found among candidates: " + candidates.keySet());
}