<?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:context="http://www.springframework.org/schema/context"
xmlns:jdbc="http://www.springframework.org/schema/jdbc"
xmlns:jee="http://www.springframework.org/schema/jee"
xmlns:tx="http://www.springframework.org/schema/tx"
xmlns:aop="http://www.springframework.org/schema/aop"
xmlns:mvc="http://www.springframework.org/schema/mvc"
xmlns:util="http://www.springframework.org/schema/util"
xmlns:jpa="http://www.springframework.org/schema/data/jpa"
xsi:schemaLocation="
http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.2.xsd
http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-3.2.xsd
http://www.springframework.org/schema/jdbc http://www.springframework.org/schema/jdbc/spring-jdbc-3.2.xsd
http://www.springframework.org/schema/jee http://www.springframework.org/schema/jee/spring-jee-3.2.xsd
http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-3.2.xsd
http://www.springframework.org/schema/data/jpa http://www.springframework.org/schema/data/jpa/spring-jpa-1.3.xsd
http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-3.2.xsd
http://www.springframework.org/schema/mvc http://www.springframework.org/schema/mvc/spring-mvc-3.2.xsd
http://www.springframework.org/schema/util http://www.springframework.org/schema/util/spring-util-3.2.xsd">
<!-- 引用的方式注入集合类型的值 -->
<util:list id='citiesBean'>
<value>北京</value>
<value>上海</value>
<value>长沙</value>
</util:list>
<util:set id="interestBean">
<value>钓鱼</value>
<value>做饭</value>
<value>台球</value>
</util:set>
<util:map id="scoreBean">
<entry key="english" value="100" />
<entry key="math" value="90" />
</util:map>
<util:properties id="dbBean">
<prop key="user">tom</prop>
<prop key="password">1234</prop>
</util:properties>
<bean id="msg" class="ioc.MessageBean">
<property name="cities" ref="citiesBean" />
<property name="interest" ref="interestBean"/>
<property name="score" ref="scoreBean"></property>
<property name="db" ref="dbBean"></property>
<property name="name" value="Ward"></property>
</bean>
<!-- 读取properties文件的内容 让spring容器读取指定位置的properties内容
存放到properties对象中,
classpath:内部的约定,根据classpath找-->
<util:properties id="config" location="classpath:config.properties"/>
<!-- Spring表达式来访问其他的bean属性 -->
<bean id="eb" class="ioc.ExampleBean">
<property name="ename" value="#{msg.name}"></property>
<property name="city" value="#{msg.cities[1]}"></property>
<!-- 下面读取math的分数也可以不写成msg.score.math
把配置文件的内容已经读到bean里面了,通过util:map id="scoreBean 的id也可以读取-->
<property name="score" value="#{scoreBean.math}"></property>
<property name="pageSize" value="#{config.pageSize}"></property>
</bean>
</beans>
-------------------------------------------------------------------------------------------------------------------------------------
<?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:context="http://www.springframework.org/schema/context"
xmlns:jdbc="http://www.springframework.org/schema/jdbc"
xmlns:jee="http://www.springframework.org/schema/jee"
xmlns:tx="http://www.springframework.org/schema/tx"
xmlns:aop="http://www.springframework.org/schema/aop"
xmlns:mvc="http://www.springframework.org/schema/mvc"
xmlns:util="http://www.springframework.org/schema/util"
xmlns:jpa="http://www.springframework.org/schema/data/jpa"
xsi:schemaLocation="
http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.2.xsd
http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-3.2.xsd
http://www.springframework.org/schema/jdbc http://www.springframework.org/schema/jdbc/spring-jdbc-3.2.xsd
http://www.springframework.org/schema/jee http://www.springframework.org/schema/jee/spring-jee-3.2.xsd
http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-3.2.xsd
http://www.springframework.org/schema/data/jpa http://www.springframework.org/schema/data/jpa/spring-jpa-1.3.xsd
http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-3.2.xsd
http://www.springframework.org/schema/mvc http://www.springframework.org/schema/mvc/spring-mvc-3.2.xsd
http://www.springframework.org/schema/util http://www.springframework.org/schema/util/spring-util-3.2.xsd">
<!-- 配置组件扫描 ;指定包annotation才会扫描-->
<context:component-scan base-package="annotation"/>
<!-- 读取指定路径下面的properties文件内容 -->
<util:properties id="config" location="classpath:config.properties"/>
</beans>
----------------------------------------------------------------
config.properties
pageSize=10