public class test {
public static void main(String[] args){
ApplicationContext ctx = new ClassPathXmlApplicationContext("bean.xml");//读取bean.xml中的内容
Person p = ( Person ) ctx.getBean("person");
p.info();
// Person p = ctx.getBean("person",Person.class);//创建bean的引用对象
// p.info();
}
}
Q:
Person p = ( Person ) ctx.getBean("person"); 为什么 这段 要写写( Person ),不是返回对象了吗
Person p = ctx.getBean("person",Person.class); 这样写又可以
新手 请担待~
慕后森
九州编程
相关分类