spring基础配文件

来源:互联网 发布:php抽奖系统 编辑:程序博客网 时间:2024/06/06 11:01

<?xmlversion="1.0"encoding="UTF-8"?>

<beansxmlns="http://www.springframework.org/schema/beans"

xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"xmlns:aop="http://www.springframework.org/schema/aop"

xmlns:tx="http://www.springframework.org/schema/tx"xmlns:context="http://www.springframework.org/schema/context"


xsi:schemaLocation="

       http://www.springframework.org/schema/beans 

       http://www.springframework.org/schema/beans/spring-beans-3.0.xsd

       http://www.springframework.org/schema/tx 

       http://www.springframework.org/schema/tx/spring-tx-3.0.xsd

       http://www.springframework.org/schema/context

       http://www.springframework.org/schema/context/spring-context-3.0.xsd

       http://www.springframework.org/schema/aop 

       http://www.springframework.org/schema/aop/spring-aop-3.0.xsd">


<!-- <bean id="add" class="com.lanou.spring.AddCaculator"> </bean> -->

<!--scope="prototype"  不是单例,多例 ,懒加载优先级高于scope -->

<!-- init-method="toString" 对象创建时就执行 -->

<beanid="user"class="com.lanou.spring.beans.User" scope="prototype"  lazy-init="true" init-method="toString" destroy-method="destory">

<propertyname="username"value="liguocheng"></property>

<propertyname="pwd">

<value>123456</value>

</property>

<!-- value只能放四类八种和String,ref注入对象 -->

<propertyname="id"value="123"></property>

<propertyname="name">

<list>

<value>wangyu</value>

<value>xuchao</value>

<value>lilei</value>

</list>

</property>

    <!--  map -->

<propertyname="map">

<map>

<entry>

                <key>

                 <value>xuchao123</value>

                 </key>

               <value>gegege</value>

          </entry>

</map>

</property>

<!-- ********************* set   *********************** -->

<propertyname="set">

<set>

<value>110</value>

<value>111</value>

<value>112</value>

</set>

</property> 

<propertyname="array" >

<array>

<value>fuxionglong</value>

<value>luziqiang</value>

<value>guolei</value>

</array>

</property>

<propertyname="userinfo"ref="userinfo"></property>

</bean>

<beanid="userinfo"class="com.lanou.spring.beans.UserInfo">

<propertyname="phone"value="17794213370"></property>

<propertyname="email"value="2301168624@qq.com"></property>

<propertyname="id"value="11222"></property>

</bean>

<!-- 构造方法注入 -->

<beanid="tom" class="com.lanou.spring.beans.Cat"  lazy-init="true">


<constructor-arg>

<!-- 参数 -->

<value>black</value>


</constructor-arg>

<constructor-arg>

<refbean="user"/> 

</constructor-arg>

</bean> 

</beans>

原创粉丝点击