在 Micronaut,我如何获取对象数组作为配置属性
At Micronaut, how can i get object array as Configuration Properties
我有一个配置yml文件
myconf:
uri: "google.com"
objarray:
- env:
- uat
- dev
label: test
- env:
- prod
label: prod
在 Micronaut 中,我能够获得诸如
之类的对象
@ConfigurationProperties("myconf")
static class MyConf {
String uri;
List<ArrayElement> objarray;
static class ArrayElement {
List<String> env;
String label;
}
}
但它显示 objarray 有 2 个正确的元素和 env 和标签字段,但它们等于 null。
如何让这个对象数组中的值?
已解决:看来我只需要将 class 更改为 public 或添加 get/set 方法。
我有一个配置yml文件
myconf:
uri: "google.com"
objarray:
- env:
- uat
- dev
label: test
- env:
- prod
label: prod
在 Micronaut 中,我能够获得诸如
之类的对象@ConfigurationProperties("myconf")
static class MyConf {
String uri;
List<ArrayElement> objarray;
static class ArrayElement {
List<String> env;
String label;
}
}
但它显示 objarray 有 2 个正确的元素和 env 和标签字段,但它们等于 null。
如何让这个对象数组中的值?
已解决:看来我只需要将 class 更改为 public 或添加 get/set 方法。