我正在尝试使用以下代码:
ConfigurableListableBeanFactory factory = ((AbstractRefreshableApplicationContext) applicationContext)
.getBeanFactory();
factory.getDependenciesForBean(beanName)
但我面临这个错误。
java.lang.ClassCastException: org.springframework.context.support.GenericApplicationContext cannot be cast to org.springframework.context.support.AbstractRefreshableApplicationContext
如果你遇到这个问题,请提供宝贵意见,我该怎样办法?
答案 0 :(得分:2)
这是有效的
ClassPathXmlApplicationContext ctx = new ClassPathXmlApplicationContext("context.xml");
ConfigurableListableBeanFactory bf = ctx.getBeanFactory();
bf.getDependenciesForBean(beanName)