Merge remote-tracking branch 'springsource/1.4.x' into 1.5.x
This commit is contained in:
@@ -35,6 +35,7 @@ import org.springframework.boot.autoconfigure.condition.ConditionOutcome;
|
||||
import org.springframework.boot.diagnostics.FailureAnalysis;
|
||||
import org.springframework.boot.diagnostics.analyzer.AbstractInjectionFailureAnalyzer;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.core.ResolvableType;
|
||||
import org.springframework.core.type.MethodMetadata;
|
||||
import org.springframework.core.type.classreading.CachingMetadataReaderFactory;
|
||||
import org.springframework.core.type.classreading.MetadataReader;
|
||||
@@ -94,12 +95,25 @@ class NoSuchBeanDefinitionFailureAnalyzer
|
||||
}
|
||||
|
||||
private String getBeanDescription(NoSuchBeanDefinitionException cause) {
|
||||
if (cause.getBeanType() != null) {
|
||||
return "a bean of type '" + cause.getBeanType().getName() + "'";
|
||||
if (cause.getResolvableType() != null) {
|
||||
Class<?> type = extractBeanType(cause.getResolvableType());
|
||||
return "a bean of type '" + type.getName() + "'";
|
||||
}
|
||||
return "a bean named '" + cause.getBeanName() + "'";
|
||||
}
|
||||
|
||||
private Class<?> extractBeanType(ResolvableType resolvableType) {
|
||||
ResolvableType collectionType = resolvableType.asCollection();
|
||||
if (!collectionType.equals(ResolvableType.NONE)) {
|
||||
return collectionType.getGeneric(0).getRawClass();
|
||||
}
|
||||
ResolvableType mapType = resolvableType.asMap();
|
||||
if (!mapType.equals(ResolvableType.NONE)) {
|
||||
return mapType.getGeneric(1).getRawClass();
|
||||
}
|
||||
return resolvableType.getRawClass();
|
||||
}
|
||||
|
||||
private List<AutoConfigurationResult> getAutoConfigurationResults(
|
||||
NoSuchBeanDefinitionException cause) {
|
||||
List<AutoConfigurationResult> results = new ArrayList<AutoConfigurationResult>();
|
||||
@@ -203,9 +217,9 @@ class NoSuchBeanDefinitionFailureAnalyzer
|
||||
return false;
|
||||
}
|
||||
String name = cause.getBeanName();
|
||||
Class<?> type = cause.getBeanType();
|
||||
ResolvableType resolvableType = cause.getResolvableType();
|
||||
return ((name != null && hasName(candidate, name))
|
||||
|| (type != null && hasType(candidate, type)));
|
||||
|| (resolvableType != null && hasType(candidate, extractBeanType(resolvableType))));
|
||||
}
|
||||
|
||||
private boolean hasName(MethodMetadata methodMetadata, String name) {
|
||||
|
||||
Reference in New Issue
Block a user