如何为嵌套的对象列表配置spring配置元数据json?
@ConfigurationProperties(prefix = "custom-config")
public class ConfigProperties {
private boolean booleanProperty;
private List<NestedObject> listProperty = new LinkedList<>();
//getters and setters
}
public class NestedObject {
private String stringProperty;
private boolean booleanProperty;
//getters and setters
}
Run Code Online (Sandbox Code Playgroud)
这是元数据json中自动生成的内容
{
"groups": [{
"name": "custom-config",
"type": "testing.config.properties.ConfigProperties",
"sourceType": "testing.config.properties.ConfigProperties"
}],
"properties": [
{
"name": "custom-config.boolean-property",
"type": "java.lang.Boolean",
"sourceType": "testing.config.properties.ConfigProperties",
"defaultValue": false
},
{
"name": "custom-config.list-property",
"type": "java.util.List<testing.config.properties.NestedObject>",
"sourceType": "testing.config.properties.ConfigProperties"
}
],
"hints": []
}
Run Code Online (Sandbox Code Playgroud)
如何在java代码或json中配置子属性?
如下所示,编辑器无法识别子属性.