求教大神,关于获取Context
@Test
//这个是我调用Test父类获取context
public void textMoocBeanName() {
//System.out.println("textMoocBeanName : " + super.getBean("moocBeanName").hashCode());
MoocBeanName bean = super.getBean("moocBeanName");
}
//这个是我通过接口调用获取context
@Override
public void setApplicationContext(ApplicationContext applicationContext)
throws BeansException {
System.out.println("setApplicationContext : " + applicationContext.getBean(this.beanName).hashCode());
MoocBeanName bean = (MoocBeanName) applicationContext.getBean(this.beanName);
bean.aa();
}
//我在以上两种方式获取Context的时候有一个问题,就是为什么在测试类获取的Context不需要强制类型转换,而调用接口的方法则必须要强制类型转换才可以调用方法呢