【发布时间】:2022-01-13 15:16:21
【问题描述】:
我希望能够使用我的列表中的一个值作为我的带有 Spring Boot 属性的地图的键。这可能吗?
我是 spring-boot 和使用 @ConfigurationProperties 的新手。我有一个如下所示的属性类
@Data
@ConfigurationProperties(prefix = "test")
public class TestProperties{
private List<String> tableNames;
private Map<String, String> fieldNames;
}
application.properties
test.table-names[0]=car.information.table
#I would like to do something like this but I get the following error:
#Can't use '[..]' navigation for property 'test.field-names.$(test.table-names' of type java.lang.String
test.field-names.${test.table-names[0]}=Id,Model,Make,Year
#I've a workaround like this for now:
test.field-names.car\.information\.table=Id,Model,Make,Year
是否可以引用列表值作为 application.properties 中另一个属性的键?
【问题讨论】:
标签: spring-boot properties configurationproperties