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