I'm trying to setup and use a YAML as config file in my Spring Boot 1.5.1 project.
My YAML file looks like the following:
hue:
user: cdKjsOQIRY8hqweAasdmx-WMsn
ip: "http://192.168.1.69"
scenes:
sunstatus:
enabled: true
id: 93yv8JekmAneCU9
group: 1
disable:
enabled: true
id: 93yv8JekmAneCU9
group: 6
It works perfectly fine to read hue.getUser(). However, hue.getScenes() returns null for some reason. My Java code for the Hue Config looks like the following:
@Configuration
@ConfigurationProperties(prefix = "hue")
public class Hue {
private String user;
private String ip;
private Scenes scenes;
/*
* Getters and setters of course
*/
public class Scenes {
private Sunstatus sunstatus;
private Disable disable;
/*
* Getters and setters
*/
public class Sunstatus {
private boolean enabled;
private String id;
private String group;
/*
* Getters and setters
*/
}
public class Disable {
private boolean enabled;
private String id;
private String group;
/*
* Getters and setters
*/
}
}
}
I've tried as well to annotate the each class with prefix as well, both in the format of hue.scenes.sunstatus, scenes.sunstatus and just sunstatus as well.
Additionally I also tried to use the @Value annotation a bit without any luck.
It's the same results if I keep the data in application.yml or in an external file. Can always only reach getUser().
What am I doing wrong here?