Skip to content

Commit f8b6114

Browse files
committed
BeanFactoryAnnotationUtils consistently applies bean name fallback when no BeanDefinition present
Issue: SPR-11915
1 parent 0451232 commit f8b6114

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

spring-beans/src/main/java/org/springframework/beans/factory/annotation/BeanFactoryAnnotationUtils.java

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2012 the original author or authors.
2+
* Copyright 2002-2014 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -34,6 +34,7 @@
3434
* Spring's {@link Qualifier @Qualifier} annotation.
3535
*
3636
* @author Chris Beams
37+
* @author Juergen Hoeller
3738
* @since 3.1.2
3839
* @see BeanFactoryUtils
3940
*/
@@ -90,6 +91,10 @@ private static <T> T qualifiedBeanOfType(ConfigurableListableBeanFactory bf, Cla
9091
if (matchingBean != null) {
9192
return matchingBean;
9293
}
94+
else if (bf.containsBean(qualifier)) {
95+
// Fallback: target bean at least found by bean name.
96+
return bf.getBean(qualifier, beanType);
97+
}
9398
else {
9499
throw new NoSuchBeanDefinitionException(qualifier, "No matching " + beanType.getSimpleName() +
95100
" bean found for qualifier '" + qualifier + "' - neither qualifier " + "match nor bean name match!");

0 commit comments

Comments
 (0)