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>

     

    美好的每一天 代码开始
  • 相关阅读:
    VS Code 隐藏 .meta 文件
    CentOS7安装之后无法上网
    windows通过ssh方式访问CentOS7
    解决libc.so.6: version `GLIBC_2.18' not found问题
    Node.js ArrayBuffer 转为字符串
    centos7 tar, zip 解压文件命令(tar, zip)
    CentOS7安装 clang
    CentOS7开启 ssh 22端口
    MongoDB手册
    C++回调函数
  • 原文地址:https://www.cnblogs.com/jieless/p/13688064.html
Copyright © 2011-2022 走看看