zoukankan      html  css  js  c++  java
  • spring4 注入参数

    <?xml version="1.0" encoding="UTF-8"?>
    <beans xmlns="http://www.springframework.org/schema/beans"
        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="people1" class="com.java1234.entity.People">
            <property name="id" value="1"></property>
            <property name="name" value="张三"></property>
            <property name="age" value="11"></property>
        </bean>
        <!--注入bean -->
        <bean id="dog1" class="com.java1234.entity.Dog">
            <property name="name" value="Jack"></property>
        </bean>
        
        <bean id="people2" class="com.java1234.entity.People">
            <property name="id" value="1"></property>
            <property name="name" value="张三"></property>
            <property name="age" value="11"></property>
            <property name="dog" ref="dog1"></property>
        </bean>
        <!--内部bean -->
        <bean id="people3" class="com.java1234.entity.People">
            <property name="id" value="1"></property>
            <property name="name" value="张三"></property>
            <property name="age" value="11"></property>
            <property name="dog">
                <bean class="com.java1234.entity.Dog">
                    <property name="name" value="Tom"></property>
                </bean>
            </property>
        </bean>
        <!-- null值-->
        <bean id="people4" class="com.java1234.entity.People">
            <property name="id" value="1"></property>
            <property name="name" value="张三"></property>
            <property name="age" value="11"></property>
            <property name="dog">
                <null></null>
            </property>
        </bean>
        <!-- 级联属性-->
        <!-- <bean id="people5" class="com.java1234.entity.People">
            <property name="id" value="1"></property>
            <property name="name" value="张三"></property>
            <property name="age" value="11"></property>
            <property name="dog.name" value="Jack2"></property>
        </bean> -->
        <!-- 集合属性-->
        <bean id="people6" class="com.java1234.entity.People">
            <property name="id" value="1"></property>
            <property name="name" value="张三"></property>
            <property name="age" value="11"></property>
            <property name="dog" ref="dog1"></property>
            <property name="hobbies">
                <list>
                    <value>唱歌</value>
                    <value>跳舞</value>
                </list>
            </property>
            <property name="loves">  <!--set是不可以重复的 -->
                <set>
                    <value>唱歌2</value>
                    <value>跳舞2</value>
                </set>
            </property>
            <property name="works">  <!--键值对 -->
                <map>
                    <entry>
                        <key><value>上午</value></key>
                        <value>写代码</value>
                    </entry>
                    <entry>
                        <key><value>下午</value></key>
                        <value>测试代码</value>
                    </entry>
                </map>
            </property>
            <property name="addresses"> <!--属性 一般用于系统配置 -->
                <props>
                    <prop key="address1">aaaaa</prop>
                    <prop key="address2">bbbbb</prop>
                </props>
            </property>
        </bean>
        
    </beans>

    private List<String> hobbies=new ArrayList<String>();
    private Set<String> loves=new HashSet<String>();
    private Map<String,String> works=new HashMap<String,String>();
    private Properties addresses=new Properties();

  • 相关阅读:
    004-DQN
    003-sarsa
    002-Q Leaning
    001-强化学习简介
    阿里云GPU服务器配置深度学习环境-远程访问-centos,cuda,cudnn,tensorflow,keras,jupyter notebook
    003-keras模型的保存于加载
    004-linux常用命令-网络命令
    004-linux常用命令-压缩解压命令
    004-linux常用命令-添加管理员用户
    004-linux常用命令-用户管理命令
  • 原文地址:https://www.cnblogs.com/rogge7/p/7018362.html
Copyright © 2011-2022 走看看