xml 文件瘦身
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:util="http://www.springframework.org/schema/util"
xmlns:p="http://www.springframework.org/schema/p"
xmlns:c="http://www.springframework.org/schema/c"
xsi:schemaLocation=
"http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-4.2.xsd
http://www.springframework.org/schema/util
http://www.springframework.org/schema/util/spring-util-4.2.xsd"
default-autowire-candidates=""
default-destroy-method=""
default-lazy-init="false"
default-merge="false"
default-init-method=""
default-autowire="no">
这里相应的引入p c util 对于util文件,在spring文件下的shcema 的util引入最新的util 文件
p 驱动属性(setter),注入值
<bean id="bdog" class="org.com.ssh.spring.Dog" p:name="echo"/> 对于引用其他的id作为属性 属性-ref
c 驱动构造(constructs) 注入值 对于引用其他的id作为属性 属性-ref
对于util 这个比较强大,他可以
<util:constant id ="ageage1" static-field="org.com.ssh.spring.Dog.age"/>
<bean id="english" class="org.com.ssh.spring.English"
p:axes-ref="e.axes"
p:age-ref="e.age"
p:schools-ref="e.schools"
p:scores-ref="e.scores"
p:pro-ref="e.pro"
/>
<util:set id="e.axes">
<value>12</value>
<value>sldklks</value>
</util:set>
<util:constant id="e.age" static-field="org.com.ssh.spring.Dog.age"/> <!-- 静态变量赋值 -->
<util:map id="e.scores">
<entry key="english" value="89"/>
<entry key="chinese" value="56"/>
</util:map>
<util:list id="e.schools">
<value>景山</value>
<value>北京</value>
<value>天河</value>
</util:list>
<util:properties id="e.pro" location="message_en_US.properties"/>
<util:constant id ="ageage1" static-field="org.com.ssh.spring.Dog.age"/> <!--后面一定是一个静态变量,否者访问不起-->