zoukankan      html  css  js  c++  java
  • Spring xml注入 以及 xml配置

    xml  配置  

     <?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: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/aop
       http://www.springframework.org/schema/aop/spring-aop-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">
    </beans>

    注入方式

     <bean id="Addresa" class="com.cn.jieless.Addresa"/>
    
        <bean id="pojo" class="com.cn.jieless.pojo" name="pojo2">
            <!--第一种   普通值注入  直接使用value 赋值-->
            <property name="name" value="我是name"/>
            <!--第二种   bean注入   ref-->
            <property name="address" ref="Addresa"/>
            <!--第三种  数组注入-->
            <property name="books">
                <array>
                    <value>西游记</value>
                    <value>红楼梦</value>
                    <value>三国演义</value>
                    <value>水浒传</value>
                </array>
            </property>
            <!--第三种  List集合注入-->
            <property name="hobby">
                <list>
                    <value>西游记List</value>
                    <value>红楼梦List</value>
                    <value>三国演义List</value>
                    <value>水浒传List</value>
                </list>
            </property>
            <!--第三种  map集合注入-->
            <property name="card">
                <map>
                    <entry key="身份证" value="4564645465465456678"></entry>
                </map>
            </property>
            <!--第三种  set注入-->
            <property name="wife">
                <set>
                    <value>QQ飞车</value>
                    <value>QQ炫舞</value>
                    <value>穿越火线</value>
                </set>
            </property>
            <!--第三种  null注入-->
            <property name="jieW">
                <null/>
            </property>
            <!--第四种  property注入-->
            <property name="info">
                <props>
                    <prop key="driver">4564546</prop>
                    <prop key="url">hfafhafafafafaf</prop>
                    <prop key="root">root</prop>
                    <prop key="pwd">518340</prop>
                </props>
            </property>
        </bean>

     

    美好的每一天 代码开始
  • 相关阅读:
    Java中的位运算符
    华为2019年NE40E-X8,承诺命令
    华为网络设备修改console密码
    MySQL5.7 多实例
    华为防火墙域间策略全开命令
    Linux基础命令---ntpstat显示时间服务器同步
    【转载】Java程序模拟公安局人员管理系统
    redis cluster集群动态伸缩--删除主从节点
    DBUtils的使用之查询的操作
    服务治理-Resilience4j(限流)
  • 原文地址:https://www.cnblogs.com/jieless/p/13688064.html
Copyright © 2011-2022 走看看