You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When a bean is defined using a static method, findAnnotationOnBean finds an annotation from the @Configuration class to which the static @Bean method belongs. The annotation is not found if the @Bean method is not static.
beanDefinedInInstanceMethodDoesNotHaveAnnotationsFromItsConfigurationClass passes but beanDefinedInStaticMethodDoesNotHaveAnnotationsFromItsConfigurationClass fails.
The text was updated successfully, but these errors were encountered:
sbrannen
changed the title
findAnnotationOnBean finds annotations from a static @Bean method's @Configuration class
findAnnotationOnBean finds annotations from a static @Bean method's enclosing class
Apr 7, 2022
I can't understand, so, which test result is expected? first or second.
From the findAnnotationOnBean method's comment describe as follow, I think test 1 is the expected behavior, am I right?
/**
* Find an {@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 the bean's factory method (if any).
* @param beanName the name of the bean to look for annotations on
* @param annotationType the type of annotation to look for
* (at class, interface or factory method level of the specified bean)
* @return the annotation of the given type if found, or {@code null} otherwise
* @throws NoSuchBeanDefinitionException if there is no bean with the given name
* @since 3.0
* @see #getBeanNamesForAnnotation
* @see #getBeansWithAnnotation
*/
Affects: 5.3.x
When a bean is defined using a static method,
findAnnotationOnBean
finds an annotation from the@Configuration
class to which the static@Bean
method belongs. The annotation is not found if the@Bean
method is not static.The following tests illustrate this behavior:
beanDefinedInInstanceMethodDoesNotHaveAnnotationsFromItsConfigurationClass
passes butbeanDefinedInStaticMethodDoesNotHaveAnnotationsFromItsConfigurationClass
fails.The text was updated successfully, but these errors were encountered: