|
26 | 26 | import org.springframework.beans.TypeConverter;
|
27 | 27 | import org.springframework.beans.factory.BeanFactory;
|
28 | 28 | import org.springframework.beans.factory.BeanFactoryAware;
|
| 29 | +import org.springframework.beans.factory.NoSuchBeanDefinitionException; |
29 | 30 | import org.springframework.beans.factory.config.BeanDefinition;
|
30 | 31 | import org.springframework.beans.factory.config.BeanDefinitionHolder;
|
31 | 32 | import org.springframework.beans.factory.config.ConfigurableListableBeanFactory;
|
@@ -72,8 +73,8 @@ public class QualifierAnnotationAutowireCandidateResolver implements AutowireCan
|
72 | 73 | public QualifierAnnotationAutowireCandidateResolver() {
|
73 | 74 | this.qualifierTypes.add(Qualifier.class);
|
74 | 75 | try {
|
75 |
| - this.qualifierTypes.add((Class<? extends Annotation>) |
76 |
| - ClassUtils.forName("javax.inject.Qualifier", QualifierAnnotationAutowireCandidateResolver.class.getClassLoader())); |
| 76 | + this.qualifierTypes.add((Class<? extends Annotation>) ClassUtils.forName("javax.inject.Qualifier", |
| 77 | + QualifierAnnotationAutowireCandidateResolver.class.getClassLoader())); |
77 | 78 | }
|
78 | 79 | catch (ClassNotFoundException ex) {
|
79 | 80 | // JSR-330 API not available - simply skip.
|
@@ -246,9 +247,14 @@ protected boolean checkQualifier(
|
246 | 247 | if (targetAnnotation == null) {
|
247 | 248 | // Look for matching annotation on the target class
|
248 | 249 | if (this.beanFactory != null) {
|
249 |
| - Class<?> beanType = this.beanFactory.getType(bdHolder.getBeanName()); |
250 |
| - if (beanType != null) { |
251 |
| - targetAnnotation = AnnotationUtils.getAnnotation(ClassUtils.getUserClass(beanType), type); |
| 250 | + try { |
| 251 | + Class<?> beanType = this.beanFactory.getType(bdHolder.getBeanName()); |
| 252 | + if (beanType != null) { |
| 253 | + targetAnnotation = AnnotationUtils.getAnnotation(ClassUtils.getUserClass(beanType), type); |
| 254 | + } |
| 255 | + } |
| 256 | + catch (NoSuchBeanDefinitionException ex) { |
| 257 | + // Not the usual case - simply forget about the type check... |
252 | 258 | }
|
253 | 259 | }
|
254 | 260 | if (targetAnnotation == null && bd.hasBeanClass()) {
|
|
0 commit comments