我们有一下两个类,并且Gradate类继承了Student类
public class Student
public class Gradate extends Student
在applicationContext.xml文件中体现继承配置
<!-- 配置一个学生对象 -->
<bean id="student" class="com.LHB.inherit.Student">
<property name="name" value="李四" />
<property name="id" value="20" />
</bean>
<!-- 配置Gradate对象 -->
<bean id="gradate" parent="student" class="com.LHB.inherit.Gradate">
<!-- 如果自己配置属性name,age,则会替换从父对象继承的数据 -->
<property name="name" value="小明" />
<property name="degree" value="学士" />
</bean>