lenientConstructorResolution flag applies to factory methods as well

This commit is contained in:
Juergen Hoeller
2009-07-27 14:09:42 +00:00
parent e85ad67fd0
commit 1eabe2b441
3 changed files with 35 additions and 1 deletions

View File

@@ -443,6 +443,12 @@ class ConstructorResolver {
argsToUse = args.arguments;
minTypeDiffWeight = typeDiffWeight;
}
else if (typeDiffWeight < Integer.MAX_VALUE && typeDiffWeight == minTypeDiffWeight &&
!mbd.isLenientConstructorResolution()) {
throw new BeanCreationException(mbd.getResourceDescription(), beanName,
"Ambiguous factory method matches found in bean '" + beanName + "' " +
"(hint: specify index/type/name arguments for simple parameters to avoid type ambiguities)");
}
}
}