diff --git a/spring-beans/src/main/java/org/springframework/beans/factory/ListableBeanFactory.java b/spring-beans/src/main/java/org/springframework/beans/factory/ListableBeanFactory.java index f2122b2f789..0fc8d08686f 100644 --- a/spring-beans/src/main/java/org/springframework/beans/factory/ListableBeanFactory.java +++ b/spring-beans/src/main/java/org/springframework/beans/factory/ListableBeanFactory.java @@ -243,7 +243,7 @@ public interface ListableBeanFactory extends BeanFactory { throws BeansException; /** - * Find all names of beans whose {@code Class} has the supplied {@link Annotation} + * Find all names of beans which are annotated with the supplied {@link Annotation} * type, without creating corresponding bean instances yet. *

Note that this method considers objects created by FactoryBeans, which means * that FactoryBeans will get initialized in order to determine their object type. @@ -256,7 +256,7 @@ public interface ListableBeanFactory extends BeanFactory { String[] getBeanNamesForAnnotation(Class annotationType); /** - * Find all beans whose {@code Class} has the supplied {@link Annotation} type, + * Find all beans which are annotated with the supplied {@link Annotation} type, * returning a Map of bean names with corresponding bean instances. *

Note that this method considers objects created by FactoryBeans, which means * that FactoryBeans will get initialized in order to determine their object type. diff --git a/spring-beans/src/main/java/org/springframework/beans/factory/support/DefaultListableBeanFactory.java b/spring-beans/src/main/java/org/springframework/beans/factory/support/DefaultListableBeanFactory.java index 09a8c31c445..9f5a5036344 100644 --- a/spring-beans/src/main/java/org/springframework/beans/factory/support/DefaultListableBeanFactory.java +++ b/spring-beans/src/main/java/org/springframework/beans/factory/support/DefaultListableBeanFactory.java @@ -658,12 +658,6 @@ public class DefaultListableBeanFactory extends AbstractAutowireCapableBeanFacto return result; } - /** - * Find a {@link Annotation} of {@code annotationType} on the specified - * bean, traversing its interfaces and super classes if no annotation can be - * found on the given class itself, as well as checking its raw bean class - * if not found on the exposed bean reference (e.g. in case of a proxy). - */ @Override @Nullable public A findAnnotationOnBean(String beanName, Class annotationType) @@ -686,6 +680,7 @@ public class DefaultListableBeanFactory extends AbstractAutowireCapableBeanFacto } if (containsBeanDefinition(beanName)) { RootBeanDefinition bd = getMergedLocalBeanDefinition(beanName); + // Check raw bean class, e.g. in case of a proxy. if (bd.hasBeanClass()) { Class beanClass = bd.getBeanClass(); if (beanClass != beanType) { @@ -696,6 +691,7 @@ public class DefaultListableBeanFactory extends AbstractAutowireCapableBeanFacto } } } + // Check annotations declared on factory method, if any. Method factoryMethod = bd.getResolvedFactoryMethod(); if (factoryMethod != null) { MergedAnnotation annotation = diff --git a/spring-context/src/main/java/org/springframework/context/annotation/Configuration.java b/spring-context/src/main/java/org/springframework/context/annotation/Configuration.java index a2a616979bf..33f38bdf14a 100644 --- a/spring-context/src/main/java/org/springframework/context/annotation/Configuration.java +++ b/spring-context/src/main/java/org/springframework/context/annotation/Configuration.java @@ -433,7 +433,7 @@ public @interface Configuration { * is registered as a traditional XML bean definition, the name/id of the bean * element will take precedence. * @return the explicit component name, if any (or empty String otherwise) - * @see org.springframework.beans.factory.support.DefaultBeanNameGenerator + * @see AnnotationBeanNameGenerator */ @AliasFor(annotation = Component.class) String value() default "";