小编Ant*_*nio的帖子

在 Spring 中使用属性来制作对象列表

我正在处理 Spring 中的属性,但我对这些属性有疑问

Valores.properties

estudiante.nombre=Antonio, Juan , Maria, Raquel
estudiante.edad=28,20,21,23
Run Code Online (Sandbox Code Playgroud)

现在我有一个班级来开发 bean

public class Estudiante {

    public Estudiante() {
    }

    public Estudiante(String nombre, Integer edad) {
        super();
        this.nombre = nombre;
        this.edad = edad;
    }

    @Value("${estudiante.nombre}")
    private String nombre;

    @Value("${estudiante.edad}")  
    private Integer edad;

    public Integer getEdad() {      
        return edad;
    }

    public void setEdad(Integer edad) {     
        this.edad = edad;
    }

    public String getNombre() {     
        return nombre;
    }

    public void setNombre(String nombre) {  
        this.nombre = nombre;
    }

    @Override
    public String toString() {
        return …
Run Code Online (Sandbox Code Playgroud)

java spring properties

5
推荐指数
1
解决办法
8147
查看次数

标签 统计

java ×1

properties ×1

spring ×1