• Spring注入


    1.构造注入

    <!--01.构造注入-->
    <bean id="stu" class="cn.bdqn.zhu.Student">
              <constructor-arg index="0" value="邱少"></constructor-arg>
              <constructor-arg index="1" value="20"></constructor-arg>
              <constructor-arg index="2" ref="car"></constructor-arg>
          </bean>

    2.p命名空间注入

    <!--02.p命名空间注入-->
    <bean id="stu" class="cn.bdqn.zhu.Student" p:name="邱少" p:age="20" p:car-ref="car">
    
        </bean>

    3.集合属性注入

    3.1 Array

    <!--Array-->
        <bean id="array" class="cn.bdqn.zhu.MyCollection">
            <property name="array">
                <array>
                    <value>呵呵</value>
                    <value>哈哈</value>
                    <value>嘿嘿</value>
                </array>
            </property>
        </bean>

    3.2 List

     <!--List-->
        <bean id="list" class="cn.bdqn.zhu.MyCollection">
            <property name="list">
                <list>
                    <value>呵呵</value>
                    <value>哈哈</value>
                    <value>嘿嘿</value>
                </list>
            </property>
        </bean>

    3.3set

    <!--set-->
        <bean id="set" class="cn.bdqn.zhu.MyCollection">
            <property name="set">
                <set>
                    <value>呵呵</value>
                    <value>哈哈</value>
                    <value>嘿嘿</value>
                </set>
            </property>
        </bean>

    3.4 Map

    <!--Map-->
        <bean id="map" class="cn.bdqn.zhu.MyCollection">
            <property name="map">
                <map>
                    <entry key="001" value="呵呵"></entry>
                    <entry key="002" value="啊啊"></entry>
                    <entry key="003">
                        <value>哦哦</value>
                    </entry>
                </map>
            </property>
        </bean>

    3.5 properties

      <!--properties-->
        <bean id="properties" class="cn.bdqn.zhu.MyCollection">
            <property name="properties">
                <props>
                    <prop key="001">
                        ljl
                    </prop>
                    <prop key="002">
                        lb
                    </prop>
                    <prop key="003">
                        lcx
                    </prop>
                </props>
            </property>
        </bean>
  • 相关阅读:
    easyExcel入门
    UML-从需求到设计--迭代进化
    UML-操作契约总结
    102. Binary Tree Level Order Traversal
    98. Validate Binary Search Tree
    95. Unique Binary Search Trees II
    96. Unique Binary Search Trees
    94. Binary Tree Inorder Traversal
    84. Largest Rectangle in Histogram
    92. Reverse Linked List II
  • 原文地址:https://www.cnblogs.com/qjt970518--/p/7240834.html
Copyright © 2020-2023  润新知