javaee spring依赖注入之spel方式

spring依赖注入之spel方式

		<dependency>
      <groupId>org.springframeworkgroupId>
      <artifactId>spring-expressionartifactId>
      <version>4.3.18.RELEASEversion>
    dependency>
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 num;
    private int[] arr;

    private Drink[] drinkArr;

    private List<String> stringList;

    private List<Drink> drinkList;

    private Map<String,Drink> map;

    public int getNum() {
        return num;
    }

    public void setNum(int num) {
        this.num = num;
    }

    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="testSpel" class="com.test.spel.TestSpel"/>

    
    <bean id="aa2" class="com.test.pojo.AA">

        <property name="num" value="#{3*4}" />

        <property name="drinkList" value="#{testSpel.getDrinkList()}" />

    bean>

    
    <bean id="aa3" class="com.test.pojo.AA">

        <property name="drinkList" value="#{T(com.test.spel.TestSpel).getDrinkList2()}" />

    bean>

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