通过XML创建装配bean

1.装配不存在成员变量的bean


<bean id="talent" class="cn.jqzhong.Spring.study.day2.LiteraryTalent"></bean>

2.装配存在成员变量的bean

2.1通过构造器注入

2.1.1属性值为引用类型、引用类型列表

<bean id="people" class="cn.jqzhong.Spring.study.day2.LikeMePeople">
  <constructor-arg ref="talent"></constructor-arg><constructor-arg>
    <list>
      <ref bean=""></ref>
      <ref bean=""></ref>
    </list>
  </constructor-arg>
</bean>

2.1.2属性值为字面值、字面值类型列表

<bean id="people" class="cn.jqzhong.Spring.study.day2.LikeMePeople">
  <constructor-arg value="xxx"></constructor-arg>
  <constructor-arg>
    <list>
      <value>xxx</value>
      <value>xxx</value>
    </list>
  </constructor-arg>
</bean>

2.2通过属性设置

2.2.1属性值为引用类型、引用类型列表

<bean id="people" class="cn.jqzhong.Spring.study.day2.LikeMePeople">
  <property name="talent" ref="talent"></property>
  <property>
    <list>
      <ref bean=""></ref>
      <ref bean=""></ref>
    </list>
  </property>

</bean>

2.2.2属性值为属性值为字面值、字面值类型列表

<bean id="people" class="cn.jqzhong.Spring.study.day2.LikeMePeople">
  <property name="talent" value="xxx"></property>
  <property name="otherTlent">
    <list>
      <value>xxx</value>
      <value>xxx</value>
    </list>
  </property>
</bean>

最新文章

  1. 【poj2096】Collecting Bugs
  2. Python 正则表达式:只要整数和小数
  3. Json.net对于导航属性的处理(解决对象循环引用)
  4. [SQL]一组数据中Name列相同值的最大Je与最小je的差
  5. Pandas系列教程——写在前面
  6. mysql并发复制系列 一:binlog组提交
  7. 构建本地yum源之rpmbuild问题汇总
  8. mac下的改装人生——关于ssd
  9. oracle 异常管理
  10. linux下的DNS
  11. Kali Rolling在虚拟机安装后的设置
  12. 前端基本知识(四):JS的异步模式:1、回调函数;2、事件监听;3、观察者模式;4、promise对象
  13. 一步一步从原理跟我学邮件收取及发送 12.telnet命令行收一封信pop3
  14. mysql 执行sql流程
  15. CentOS6.5 安装vncserver实现图形化访问
  16. HDU4460
  17. bzoj4985 评分 (二分答案+dp)
  18. Gym - 100851F - Froggy Ford(dijkstra)
  19. hadoop发行版本之间的区别
  20. openstack cpu pinning

热门文章

  1. Python头脑风暴3
  2. Android后台的linux一直保持唤醒状态,不进入睡眠
  3. Python 前端的第三方库
  4. LPSTR LPCSTR LPWSTR LPCWSTR区别
  5. STW Family
  6. hashlib.md5加密
  7. [python][oldboy]strip
  8. Get Sauce(状压DP)
  9. 【bzoj2752】[HAOI2012]高速公路(road) 线段树
  10. 关闭chrome浏览器的input香蕉黄背景