mercredi 31 janvier 2018

YML file dosn't work with spring boot

I have a problem and i really don't know how to solve it, and for me it doesn't make sens. Can anyone tell me where is the mistake because i can't see it. I am using spring-boot

Here I have the yml file:

spring:
   profiles: dev
 devices: 
  list: 
- id : TV1
  type : TV
  value : boolean
  name : TV_sufragerie
- id : TV2
  type : TV  
  value : boolean
  name : TV_dormitor
- id : Therme1
  type : Therme
  value : Double
  name : Therme-hol
- id : SmartBulb1
  type : SmartBulb
  value : SmartBulbValue
  name : SmartBulbDormitor

And this is how I try to take the data from the yml file:

@Component
@ConfigurationProperties("devices")
public class DeviceYml {

private List<DevicesList> list = new ArrayList<>();

public static class DevicesList {

    private String id;

    private  String type ;

    private List<String> value = new ArrayList<>();

    private String name;

    public String getId() {
        return id;
    }

    public void setId(String id) {
        this.id = id;
    }

    public String getType() {
        return type;
    }

    public void setType(String type) {
        this.type = type;
    }

    public List<String> getValue() {
        return value;
    }

    public void setValue(List<String> value) {
        this.value = value;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    @Override
    public String toString() {
        return "YAMLConfigDevice [id=" + id + ", type=" + type + ", value=" + value + ", name=" + name + "]";
    }

}
public List<DevicesList> getDevices() {
    return list;
}

public void setDevices(List<DevicesList> list) {
    this.list = list;
}

@Override
public String toString() {
    return "devicesList=" + list + "";
}
}

I alsow have in the applicaton.properties this:

spring.profiles.active=dev




Aucun commentaire:

Enregistrer un commentaire