• SPringioc的配置文件 依赖注入的几种方法


    <?xml version="1.0" encoding="UTF-8"?>
    <beans xmlns="http://www.springframework.org/schema/beans"
    xmlns:p="http://www.springframework.org/schema/p"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://www.springframework.org/schema/beans
    http://www.springframework.org/schema/beans/spring-beans.xsd">
    <!--构造方法注入-->
    <bean id="user" class="cn.domain.User">
    <constructor-arg index="0" value="2"></constructor-arg>
    <constructor-arg index="1" value="无芒"></constructor-arg>
    <constructor-arg index="2" ref="time"></constructor-arg>
    <constructor-arg index="3" value="热门"></constructor-arg>
    </bean>
    <bean id="time" class="java.util.Date"></bean>
    <!--set注入-->
    <bean id="user1" class="cn.domain.User">
    <property name="id" value="5"></property>
    <property name="name" value="无痕"></property>
    <property name="shijian" ref="time"></property>
    <property name="re" value="不热门"></property>
    </bean>
    <!--p名称空间 需要在第二行代码处加入
      xmlns:p="http://www.springframework.org/schema/p"
    -->
    <bean id="user2" class="cn.domain.User" p:id="9" p:name="无锋" p:shijian-ref="time" p:re="温"></bean>
    <!--集合 数组 标签的注入-->
    <bean id="user3" class="cn.domain.User">
    <property name="list">
    <set>
    <value>赵文扬</value>
    <value>赵文扬1</value>
    <value>赵文扬2</value>
    <value>赵文扬3</value>
    </set>
    </property>
    <property name="str">
    <set>
    <value>天</value>
    <value>地</value>
    <value>无</value>
    <value>双</value>
    </set>
    </property>
    <property name="map">
    <props>
    <prop key="qqq">666</prop>
    <prop key="q">6</prop>
    <prop key="qq">66</prop>
    <prop key="qqqqqq">6666666</prop>
    </props>
    </property>
    <property name="pp">
    <map>
    <entry value="a" key="刘11111"></entry>
    <entry value="aa" key="刘111"></entry>
    <entry value="aaa" key="刘11"></entry>
    <entry value="aaaa" key="刘1"></entry>
    </map>
    </property>
    </bean>



    </beans>
  • 相关阅读:
    JS学习之旅2
    JS学习之旅1
    Stack 栈
    Linked List 链表
    Array 数组
    时间/空间复杂度
    What/Why/How
    Https 握手过程
    JS跨域解决方案
    JS 的内存管理-GC
  • 原文地址:https://www.cnblogs.com/zhaowenyang/p/11322398.html
Copyright © 2020-2023  润新知