javaee spring 依赖注入之复杂类型的注入数组 集合 等

spring 依赖注入之复杂类型的注入

package com.test.pojo;

import java.util.List;
import java.util.Map;
import java.util.Properties;

/**
 * @description:
 * @projectName:testSpring
 * @see:com.test.pojo
 * @createTime:2023/8/27 14:39
 */
public class AA {
    private int[] arr;

    private Drink[] drinkArr;

    private List<String> stringList;

    private List<Drink> drinkList;

    private Map<String,Drink> map;

    private Properties properties;

    public int[] getArr() {
        return arr;
    }

    public void setArr(int[] arr) {
        this.arr = arr;
    }

    public Drink[] getDrinkArr() {
        return drinkArr;
    }

    public void setDrinkArr(Drink[] drinkArr) {
        this.drinkArr = drinkArr;
    }

    public List<String> getStringList() {
        return stringList;
    }

    public void setStringList(List<String> stringList) {
        this.stringList = stringList;
    }

    public List<Drink> getDrinkList() {
        return drinkList;
    }

    public void setDrinkList(List<Drink> drinkList) {
        this.drinkList = drinkList;
    }

    public Map<String, Drink> getMap() {
        return map;
    }

    public void setMap(Map<String, Drink> map) {
        this.map = map;
    }

    public Properties getProperties() {
        return properties;
    }

    public void setProperties(Properties properties) {
        this.properties = properties;
    }
}

<bean id="aa" class="com.test.pojo.AA">
        <property name="arr">
            <array>
                <value>1value>
                <value>2value>
                <value>3value>
            array>
        property>

        <property name="drinkArr">
            <array>
                <ref bean="drink_01" />
                <ref bean="drink_02" />
            array>
        property>

        <property name="stringList">
            <list>
                <value>tomvalue>
                <value>jackvalue>
                <value>tonyvalue>
            list>
        property>

        <property name="drinkList">
            <list>
                <ref bean="drink_01" />
                <ref bean="drink_02" />
            list>
        property>

        <property name="map">
            <map>
                <entry key="first" value-ref="drink_01" />
                <entry key="second" value-ref="drink_02"  />
            map>
        property>

        <property name="properties">
            <props>
                <prop key="driver" >com.mysql.jdbc.Driverprop>
                <prop key="url" >jdbc:mysql://localhost:3306/taobaoprop>
            props>
        property>

    bean>

你可能感兴趣的:(Mac开发,java-ee,spring,java)