• 博客园logo
  • 会员
  • 众包
  • 新闻
  • 博问
  • 闪存
  • 赞助商
  • HarmonyOS
  • Chat2DB
    • 搜索
      所有博客
    • 搜索
      当前博客
  • 写随笔 我的博客 短消息 简洁模式
    用户头像
    我的博客 我的园子 账号设置 会员中心 简洁模式 ... 退出登录
    注册 登录
java小斌
让技术填满空虚的内心世界
博客园    首页    新随笔    联系   管理    订阅  订阅

spring之继承配置

我们有一下两个类,并且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>

 

posted @ 2017-11-30 15:11  Java小斌  阅读(469)  评论(0)    收藏  举报
刷新页面返回顶部
博客园  ©  2004-2025
浙公网安备 33010602011771号 浙ICP备2021040463号-3