Wrap depends-on exception for specifically requested top-level bean
Closes gh-32470
This commit is contained in:
parent
4a10bc3288
commit
387e34d881
|
@ -316,6 +316,16 @@ public abstract class AbstractBeanFactory extends FactoryBeanRegistrySupport imp
|
|||
throw new BeanCreationException(mbd.getResourceDescription(), beanName,
|
||||
"'" + beanName + "' depends on missing bean '" + dep + "'", ex);
|
||||
}
|
||||
catch (BeanCreationException ex) {
|
||||
if (requiredType != null) {
|
||||
// Wrap exception with current bean metadata but only if specifically
|
||||
// requested (indicated by required type), not for depends-on cascades.
|
||||
throw new BeanCreationException(mbd.getResourceDescription(), beanName,
|
||||
"Failed to initialize dependency '" + ex.getBeanName() + "' of " +
|
||||
requiredType.getSimpleName() + " bean '" + beanName + "'", ex);
|
||||
}
|
||||
throw ex;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -949,7 +949,7 @@ public abstract class AbstractApplicationContext extends DefaultResourceLoader
|
|||
// Initialize LoadTimeWeaverAware beans early to allow for registering their transformers early.
|
||||
String[] weaverAwareNames = beanFactory.getBeanNamesForType(LoadTimeWeaverAware.class, false, false);
|
||||
for (String weaverAwareName : weaverAwareNames) {
|
||||
getBean(weaverAwareName);
|
||||
beanFactory.getBean(weaverAwareName, LoadTimeWeaverAware.class);
|
||||
}
|
||||
|
||||
// Stop using the temporary ClassLoader for type matching.
|
||||
|
|
Loading…
Reference in New Issue