zoukankan      html  css  js  c++  java
  • applicationContext.xml配置文件setter注入

    <?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:p="http://www.springframework.org/schema/p"
           xmlns:c="http://www.springframework.org/schema/c"
           xsi:schemaLocation="http://www.springframework.org/schema/beans
            http://www.springframework.org/schema/beans/spring-beans.xsd">
    
        <!--P(属性: properties)命名空间 , 属性依然要设置set方法-->
        <bean id="user1" class="com.kuang.pojo.User" p:name="狂神" p:age="18" scope="singleton"/>
    
        <!--C(构造: Constructor)命名空间 , 属性依然要设置set方法-->
        <bean id="user2" class="com.kuang.pojo.User" c:name="狂神" c:age="18" scope="prototype"/>
    
        <bean id="student" class="com.kuang.pojo.Student">
            <property name="name" value="小明"/>
        </bean>
    
        <bean id="addr" class="com.kuang.pojo.Address">
            <property name="address" value="重庆"/>
        </bean>
    
        <bean id="student1" class="com.kuang.pojo.Student">
            <property name="name" value="小明"/>
            <property name="address" ref="addr"/>
        </bean>
    
        <bean id="student2" class="com.kuang.pojo.Student">
            <property name="name" value="小明"/>
            <property name="address" ref="addr"/>
            <property name="books">
                <array>
                    <value>西游记</value>
                    <value>红楼梦</value>
                    <value>水浒传</value>
                </array>
            </property>
            <property name="hobbys">
                <list>
                    <value>听歌</value>
                    <value>看电影</value>
                    <value>爬山</value>
                </list>
            </property>
            <property name="card">
                <map>
                    <entry key="中国邮政" value="456456456465456"/>
                    <entry key="建设" value="1456682255511"/>
                </map>
            </property>
            <property name="games">
                <set>
                    <value>LOL</value>
                    <value>BOB</value>
                    <value>COC</value>
                </set>
            </property>
            <property name="wife"><null/></property>
            <property name="info">
                <props>
                    <prop key="学号">20190604</prop>
                    <prop key="性别">男</prop>
                    <prop key="姓名">小明</prop>
                </props>
            </property>
        </bean>
    
    </beans>
  • 相关阅读:
    IntelliJ IDEA生成 Serializable 序列化 UID 的快捷键
    spring boot rabbitmq 多MQ配置 自动 创建 队列 RPC
    JAVA使用并行流(ParallelStream)时要注意的一些问题
    深入浅出Stream和parallelStream
    JAVA8 十大新特性详解
    redis客户端连接,最大连接数查询与设置
    如何在Java 8中愉快地处理日期和时间
    Jenkins:使用Git Parameter插件实现tag或分支的选择性构建
    Java正确获取客户端真实IP方法整理
    redis问题接囧办法及经验
  • 原文地址:https://www.cnblogs.com/yslf/p/11955656.html
Copyright © 2011-2022 走看看