Spring里的applicationContext.getBeansWithAnnotation

getBeansWithAnnotation

Map<String,Object> getBeansWithAnnotation(Class<? extends Annotation> annotationType)
throws BeansException

Find all beans whose Class has the supplied Annotation type.

Parameters:
annotationType - the type of annotation to look for
Returns:
a Map with the matching beans, containing the bean names as keys and the corresponding bean instances as values
Throws:
BeansException - if a bean could not be created

相关文章