关于Spring中xml文件的parent属性
孔子在骑车 2015-04-10 10:51:56 public class Person {
private String name;
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
}
public class Student extends Person{
public void say(){
System.out.println(this.getName());
}
}
spring配置文件是:
<bean id="person" class="com.itheima09.extend.Person">
<property name="name" value="aaa"></property>
</bean>
<bean id="student" class="com.itheima09.extend.Student" >
</bean>
问题是:
为毛调用student的say方法,输出的值是null?他的父类parent属性name不都已经依赖注入了属性值“aaa”了吗?
要想在student中输出name 要在student的<bean>中写parent属性,为毛呀?不写怎么就不行了 student 已经extends person了呀!!!