Search code examples
javaconfigurationannotationsmicronaut

At Micronaut, how can i get object array as Configuration Properties


I have a configuration yml file

myconf:
  uri: "google.com"
  objarray:
  - env:
    - uat
    - dev
    label: test
  - env:
    - prod
    label: prod

In Micronaut i am able to get objects such as

@ConfigurationProperties("myconf")
static class MyConf {

    String uri;

    List<ArrayElement> objarray;

    static class ArrayElement {

        List<String> env;

        String label;
    }
}

But it shows objarray having 2 elements correctly with env and label fields but they are equal to null.

How can i let the values within this object array?


Solution

  • Solved: It seems i only needed to change the class to public or add get/set methods.