一、bean之间的关系

<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:p="http://www.springframework.org/schema/p"
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd">
<bean id="car" class="spring.beans.autowire.Car"
p:carName="奥迪^" p:price="300000"></bean> <!-- 继承 -->
<bean id="car2" class="spring.beans.autowire.Car"
p:price="100000" parent="car"></bean> <!-- 抽象类 -->
<bean id="address1" p:city="重庆" abstract="true"></bean> <bean id="address" class="spring.beans.autowire.Address"
p:more="梁平" parent="address1"></bean> <!-- 依赖 -->
<bean id="person" class="spring.beans.relation.Person" p:name="张三" p:car-ref="car"
depends-on="address" p:address-ref="address">
</bean> </beans>

二、bean的作用域

  常用的两个作用域就是scope="singleton"和scope="prototype"

<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd"> <!-- bean的作用域 scope-->
<bean id="car" class="spring.beans.scope.Car" scope="prototype">
<property name="name" value="奥迪"></property>
<property name="price" value="300000"></property>
</bean> </beans>

最新文章

  1. 警惕自己,不断学习c++【转】
  2. centos7 gitlab
  3. POJ 1094 Sorting It All Out 拓扑排序 难度:0
  4. Checking the content of the pointer
  5. 可配置多功能门 SN74LVC1G57, 1G58, 1G97, 1G98, 1G99
  6. 关于MySql entity framework 6 执行like查询问题解决方案
  7. MySQL在线备份与恢复工具 --&gt; Xtrabackup
  8. WPF combobox 圆角制作
  9. iOS: TableView如何刷新指定的cell 或section
  10. Log4net 日志记录配置信息
  11. javascript 三种弹出对话框
  12. 使用原生php爬取图片并保存到本地
  13. 前端面试之Javascript
  14. ecmall 如何新增挂件
  15. 解决Myeclipse ctrl+h带来的困扰
  16. 恺撒密码 I Python实现
  17. 15. DML, DDL, LOGON 触发器
  18. [leetcode]253. Meeting Rooms II 会议室II
  19. 某个php爬虫程序分析--来自wooyun
  20. Learning Phrase Representations using RNN Encoder–Decoder for Statistical Machine Translation

热门文章

  1. 【BZOJ4245】[ONTAK2015]OR-XOR 贪心
  2. hihoCoder 1549 或运算和
  3. 浅谈Spring框架注解的用法分析
  4. 【转】IBM PowerVM虚拟化技术笔记
  5. python下多线程的限制以及多进程中传递参数的方式
  6. Java基础—复用类
  7. Kafka配置参数说明
  8. Centos(Yum源更改)
  9. 字典树 trie树 学习
  10. flex label 换行