下面是我的yaml配置。
configuration:
internalUser:
add:
city:
path: path
name: cityName
country:
path: path
name: countryName
replace:
city:
path: path
name: cityName
remove:
city:
path: path
name: cityName
externalUser:
add:
city:
path: path
name: cityName
country:
path: path
name: countryName
replace:
city:
path: path
name: cityName
remove:
city:
path: path
name: cityName
配置类如下:
@ConfigurationProperties(prefix = "configuration")
public class Configuration {
private Map<String, Map<String,Map<String>,Address>>> internalUser = new HashMap<>();
//setter and getter
}
Public class Address{
private String path;
private String name;
//setter and getter
}
在加载应用程序时,它失败并且无法投射对象。
我的配置有什么问题吗?或者我们可以使用嵌套配置进行此配置吗? 请帮助我进行配置。
答案 0 :(得分:1)
您的地图太多了。
第一个键:add, replace, remove
第二个键:city
@ConfigurationProperties(prefix = "configuration")
public class Configuration {
private Map<String, Map<String, Address>>> internalUser;
private Map<String, Map<String, Address>>> externalUser;
//setter and getter
}