码迷,mamicode.com
首页 > 编程语言 > 详细

spring简单配置

时间:2015-02-16 19:34:19      阅读:179      评论:0      收藏:0      [点我收藏+]

标签:

 1 <?xml version="1.0" encoding="utf-8"?>
 2 <beans xmlns="http://www.springframework.org/schema/beans"
 3     xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:p="http://www.springframework.org/schema/p"
 4     xmlns:context="http://www.springframework.org/schema/context"
 5     xmlns:jee="http://www.springframework.org/schema/jee" xmlns:tx="http://www.springframework.org/schema/tx"
 6     xsi:schemaLocation="
 7             http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.5.xsd
 8             http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-2.5.xsd
 9             http://www.springframework.org/schema/jee http://www.springframework.org/schema/jee/spring-jee-2.5.xsd
10             http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-2.5.xsd">
11     <bean id="department" class="com.ruby.collection.Department">
12         <property name="name" value="财政部"></property>
13         <!-- 给数组注入值 -->
14         <property name="empName">
15             <list>
16                 <value>小明</value>
17                 <value>小李</value>
18                 <value>小张</value>
19             </list>
20         </property>
21         
22         <!-- 给list注入值 -->
23         <property name="empList">
24             <list>
25                 <ref bean="emp1"></ref>
26                 <ref bean="emp2"></ref>
27             </list>
28         </property>
29         
30         <!-- 给Set注入值 -->
31         <property name="empSet">
32             <set>
33                 <ref bean="emp1"></ref>
34                 <ref bean="emp2"></ref>
35             </set>
36         </property>
37         
38         <!-- 给Map注入值 -->
39         <property name="empMap">
40             <map>
41                 <entry key="1" value-ref="emp1"></entry>
42                 <entry key="2" value-ref="emp2"></entry>
43             </map>
44         </property>
45     </bean>
46     
47     <bean id="emp1" class="com.ruby.collection.Employee">
48         <property name="name" value="ruby"></property>
49         <property name="id" value="1"></property>
50     </bean>
51     <bean id="emp2" class="com.ruby.collection.Employee">
52         <property name="name" value="Lua"></property>
53         <property name="id" value="2"></property>
54     </bean>
55 </beans>

 

spring简单配置

标签:

原文地址:http://www.cnblogs.com/eleven24/p/4294445.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!