I am trying to configure and use YAML as a configuration file in my Spring Boot 1.5.1 project.
My YAML file is as follows:
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 great to read hue.getUser (). However, hue.getScenes () for some reason returns null. My Java code for Hue Config is as follows:
@Configuration
@ConfigurationProperties(prefix = "hue")
public class Hue {
private String user;
private String ip;
private Scenes scenes;
public class Scenes {
private Sunstatus sunstatus;
private Disable disable;
public class Sunstatus {
private boolean enabled;
private String id;
private String group;
}
public class Disable {
private boolean enabled;
private String id;
private String group;
}
}
}
I also tried to annotate each class with a prefix, both in the format hue.scenes.sunstatus, scenes.sunstatus, and just sunstatus.
In addition, I also tried using the @Value annotation for a bit of luck.
These are the same results if I save the data in application.yml or in an external file. Only getUser () can always reach.
What am I doing wrong here?