假设我有以下代码来定义someBean
:
@Bean
public SomeInterface someBean() {
return new SomeInterfaceImpl();
}
我想在运行时从spring容器中获取此bean的接口类型,即SomeInterface
。我尝试了以下代码,但我发现def
对象对SomeInterface
一无所知。
ApplicationContext container = new AnnotationConfigApplicationContext...
BeanDefinition def = container.getBeanDefinition("someBean");
是否可以仅从container
对象获取它?如果可能的话,请告诉我如何。提前谢谢。