Skip to content

Commit f2478cf

Browse files
committed
Contextual BeanCreationException in case of depending on a missing bean
Issue: SPR-16628 (cherry picked from commit 937cd48)
1 parent 977084a commit f2478cf

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

spring-beans/src/main/java/org/springframework/beans/factory/support/AbstractBeanFactory.java

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -293,7 +293,13 @@ protected <T> T doGetBean(
293293
"Circular depends-on relationship between '" + beanName + "' and '" + dep + "'");
294294
}
295295
registerDependentBean(dep, beanName);
296-
getBean(dep);
296+
try {
297+
getBean(dep);
298+
}
299+
catch (NoSuchBeanDefinitionException ex) {
300+
throw new BeanCreationException(mbd.getResourceDescription(), beanName,
301+
"'" + beanName + "' depends on missing bean '" + dep + "'", ex);
302+
}
297303
}
298304
}
299305

0 commit comments

Comments
 (0)