Browse Source

improved "no matching factory method found" exception message (SPR-6837)

pull/23217/head
Juergen Hoeller 16 years ago
parent
commit
18bd4a8337
  1. 14
      org.springframework.beans/src/main/java/org/springframework/beans/factory/support/ConstructorResolver.java

14
org.springframework.beans/src/main/java/org/springframework/beans/factory/support/ConstructorResolver.java

@ -484,14 +484,14 @@ class ConstructorResolver { @@ -484,14 +484,14 @@ class ConstructorResolver {
factoryMethodToUse = candidate;
argsToUse = args.arguments;
minTypeDiffWeight = typeDiffWeight;
ambiguousFactoryMethods = null;
ambiguousFactoryMethods = null;
}
else if (factoryMethodToUse != null && typeDiffWeight == minTypeDiffWeight) {
if ( ambiguousFactoryMethods == null) {
ambiguousFactoryMethods = new LinkedHashSet<Method>();
ambiguousFactoryMethods.add(factoryMethodToUse);
if (ambiguousFactoryMethods == null) {
ambiguousFactoryMethods = new LinkedHashSet<Method>();
ambiguousFactoryMethods.add(factoryMethodToUse);
}
ambiguousFactoryMethods.add(candidate);
ambiguousFactoryMethods.add(candidate);
}
}
}
@ -501,7 +501,9 @@ class ConstructorResolver { @@ -501,7 +501,9 @@ class ConstructorResolver {
"No matching factory method found: " +
(mbd.getFactoryBeanName() != null ?
"factory bean '" + mbd.getFactoryBeanName() + "'; " : "") +
"factory method '" + mbd.getFactoryMethodName() + "'");
"factory method '" + mbd.getFactoryMethodName() + "'. " +
"Check that a method of the specified name exists and that it is " +
(isStatic ? "static" : "non-static") + ".");
}
else if (void.class.equals(factoryMethodToUse.getReturnType())) {
throw new BeanCreationException(mbd.getResourceDescription(), beanName,

Loading…
Cancel
Save