// contains the beanNames resolved based on the method signature
final Set<String> noArgMethodsSeen = new HashSet<String>();
ReflectionUtils.doWithMethods(configurationClass, new MethodCallback() {
public void doWith(Method m) throws IllegalArgumentException, IllegalAccessException {
Bean beanAnnotation = AnnotationUtils.findAnnotation(m, Bean.class);
// Determine bean name
String beanName = beanNamingStrategy.getBeanName(m);
if (beanAnnotation != null) {
if (!noArgMethodsSeen.contains(beanName)) {
// If the bean already exists in the factory, don't emit
// a bean definition. This may or may not be legal,
// depending on whether the @Bean annotation allows
// overriding
if (owningBeanFactory.containsLocalBean(beanName)) {
if (!beanAnnotation.allowOverriding()) {
String message = format(
"A bean named '%s' already exists. Consider using @Bean(allowOverriding=true)",
beanName);
throw new IllegalStateException(message);
}