Spring -配置集合属性
1 可使用<list> <map> <set>等来配置集合属性
2 List
<!-- 配置List属性 -->
<bean id="person3" class="com.kejian.spring.bean.collectionbean.PersonForList">
<property name="name" value="Peter"></property>
<property name="age" value="30"></property>
<property name="cars">
<list>
<ref bean="car1"/>
<ref bean="car2"/>
</list>
</property>
</bean>
3 Map
<!-- 配置Map属性 -->
<bean id="person4" class="com.kejian.spring.bean.collectionbean.PersonForMap">
<property name="name" value="Mike"></property>
<property name="age" value="35"></property>
<property name="cars">
<map>
<entry key="ACar" value-ref="car1"></entry>
<entry key="BCar" value-ref="car2"></entry>
</map>
</property>
</bean>
4 Props:配置properties
<!-- 通过props来配置properties -->
<bean id="datasource" class="com.kejian.spring.bean.collectionbean.Datasource">
<property name="properties">
<props>
<prop key="user">root</prop>
<prop key="password">root</prop>
<prop key="url">jdbc:mysql.///test</prop>
<prop key="driver">jdbc.mysql.driver</prop>
</props>
</property>
</bean>
5 单独配置集合bean:需引入Util shema
<!-- 单独配置集合 -->
<util:list id="cars">
<ref bean="car1"/>
<ref bean="car2"/>
</util:list>
6 使用p shema更快捷配置bean属性:需引入p shema
<!-- 通过p命名空间来配置bean属性 -->
<bean id="person5" class="com.kejian.spring.bean.collectionbean.PersonForList"
p:name="Jack" p:age="22" p:cars-ref="cars">
</bean>
Spring -配置集合属性的更多相关文章
- Spring基础07——配置集合属性
1.集合属性 在Spring中可以通过一组内置的xml标签(例如<list>,<set>或<map>)来配置集合属性. 2.配置List集合 配置java.util ...
- Spring学习--集合属性
Spring 中可以通过一组内置的 xml 标签(例如: <list> , <set> 或 <map>) 来配置集合属性. 配置java.util.Set 需要使用 ...
- [原创]java WEB学习笔记98:Spring学习---Spring Bean配置及相关细节:如何在配置bean,Spring容器(BeanFactory,ApplicationContext),如何获取bean,属性赋值(属性注入,构造器注入),配置bean细节(字面值,包含特殊字符,引用bean,null值,集合属性list map propert),util 和p 命名空间
本博客的目的:①总结自己的学习过程,相当于学习笔记 ②将自己的经验分享给大家,相互学习,互相交流,不可商用 内容难免出现问题,欢迎指正,交流,探讨,可以留言,也可以通过以下方式联系. 本人互联网技术爱 ...
- spring 配置属性的详细信息
摘要(这篇文章讲的红,蓝说这话节) 字面值 字面值:可用字符串表示的值,能够通过<value>元素标签或value属性进行注入 基本数据类型及其封装类.String等类型都能够採取字面值注 ...
- Spring(八):Spring配置Bean(一)BeanFactory&ApplicationContext概述、依赖注入的方式、注入属性值细节
在Spring的IOC容器里配置Bean 配置Bean形式:基于xml文件方式.基于注解的方式 在xml文件中通过bean节点配置bean: <?xml version="1.0&qu ...
- Spring容器的属性配置详解的六个专题
在spring IOC容器的配置文件applicationContext.xml里,有一些配置细节值得一提.我们将一些问题归结为以下几个专题. 专题一:字面值问题 配置的bean节点中的值,我们提 ...
- spring 配置属性细节
版权声明:本文为博主原创文章.未经博主同意不得转载. https://blog.csdn.net/qilixiang012/article/details/28233811 概要(红色为上一篇所讲,蓝 ...
- spring 配置bean
Main(测试方法) public class Main { public static void main(String[] args) { //1.创建Spring 的IOC容器对象: //spr ...
- Spring4学习笔记2-配置集合属性
1 可使用<list> <map> <set>等来配置集合属性 2 List <!-- 配置List属性 --> <bean id="p ...
随机推荐
- 【leetcode】Plus One (easy)
Given a non-negative number represented as an array of digits, plus one to the number. The digits ar ...
- ZendStudio如何汉化
点击工具栏的help,看图 点击 Install New Sofaware... 看图 然后.... 在地址(12.0的版本):http://download.eclipse.org/techno ...
- Hibernate单向一对多对象关系模型映射
1 hibernate 的对象关系映射 Orm: 类-----表 属性------字段 对象------记录 表:在数据库中存在主外键的关系,反向工厂类是由表生成,在由表生成类的时候,类和类之间存在者 ...
- VB.NET 注册表基本操作
''' <summary> ''' 注册表设置值 ''' </summary> ''' <param name="strKey"></pa ...
- gcc提供的原子操作函数
gcc从4.1.2提供了__sync_*系列的built-in函数,用于提供加减和逻辑运算的原子操作.其声明如下: type __sync_fetch_and_add (type *ptr, type ...
- 模拟赛1030d1
[问题描述]从1− ?中找一些数乘起来使得答案是一个完全平方数,求这个完全平方数最大可能是多少.[输入格式]第一行一个数字?.[输出格式]一行一个整数代表答案对100000007取模之后的答案.[样例 ...
- Navicat 回复 psc 文件 Mysql
在mysql 中回复 psc文件 的时候 只能一步步来,先在navicat中建一个空数据库,然后点击有上角的备份==>回复备份==> 找到psc文件==> 注意此时不要急于点击 开始 ...
- 自动复制转换StringBuffer
自动复制转换StringBuffer http://www.cnblogs.com/coqn/archive/2012/07/31/all_StringBuufer.html http://blog. ...
- HTTPS的一些疑问解答
PHP写的网站怎么用https访问,具体要怎样 这跟用什么语言写的网站没有关系,可以去申请个快速的SSL证书,一年也就几十块. 开启apache server的ssl,自己做个免费的ssl证书或者去申 ...
- 【翻译三】java-并发之线程对象和实现
Thread Objects Each thread is associated with an instance of the class Thread. There are two basic s ...