Java 是否可以使用Spring和@Value注释将YAML属性读入地图
我希望能够做到的是: 亚马尔: 代码:Java 是否可以使用Spring和@Value注释将YAML属性读入地图,java,spring,yaml,spring-el,Java,Spring,Yaml,Spring El,我希望能够做到的是: 亚马尔: 代码: @Value(“${features}”) 私有地图特征; 我不知道使用什么样的Spring脚本语法来实现这一点(如果可能的话)我正在使用Spring引导并访问如下自定义变量: features: feature1: true feature2: false feature3: true 创建映射到自定义属性的自定义类: @Component @ConfigurationProperties(prefix="features") publi
@Value(“${features}”)
私有地图特征;
我不知道使用什么样的Spring脚本语法来实现这一点(如果可能的话)我正在使用Spring引导并访问如下自定义变量:
features:
feature1: true
feature2: false
feature3: true
@Component
@ConfigurationProperties(prefix="features")
public class ConstantProperties {
private String feature1;
public String getFeature1(){
return feature1;
}
public void setFeature1(String feature1) {
this.feature1 = feature1;
}
}
features:
feature1: true
feature2: false
feature3: true
@Autowire
private ConfigurationProperties configurationProperties;
configurationProperties.getFeature1();
"{{features.feature1}}"
"{{features.feature1}}"