findAnnotationOnBean only falls back to bean class in case of no factory method

Most importantly, static @Bean methods do not expose their @Configuration class-level annotations anymore, aligned with the behavior for non-static @Bean methods.

Closes gh-28298
This commit is contained in:
Juergen Hoeller
2022-06-14 14:01:38 +02:00
parent 083113d8a4
commit a14650e0dc
2 changed files with 8 additions and 5 deletions

View File

@@ -745,7 +745,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()) {
if (bd.hasBeanClass() && bd.getFactoryMethodName() == null) {
Class<?> beanClass = bd.getBeanClass();
if (beanClass != beanType) {
MergedAnnotation<A> annotation =