我正试图使用quarkus-yaml扩展作为配置的主要来源,并试图找出从yaml文件加载映射的最佳方法。
application.yml
:
quarkus:
http:
port: 8080
configuration:
value:
name1: test1
name2: test2
name3: test3
在代码中,我尝试注入如下配置值:
@ConfigProperty(name = "configuration.value")
Values value;
其中Values包含自定义Eclipse Microprofile Converter。转换器看起来像这样:
public class ValueConverter implements Converter<Values> {
@Override
public Values convert(String value) {
// Here there would be the actual code to convert to Map.
return new Values(map);
}
}
问题是String值为空,即它没有加载以下配置的stull。值:
name1: test1
name2: test2
name3: test3
我还尝试过用@ConfigProperties(prefix = "configuration.value")
注释一个类,并且在里面有一个映射,但它不知道如何将其映射到预期的Map
。。。有没有办法创建自定义配置属性转换器?
这是Eclipse微配置文件的问题吗?这是个虫子吗?这是功能请求吗?:(或者,还有其他更好的方法吗?
谢谢你的帮助!
正如邮件列表中所回答的,Eclipse MicroProfile Config不支持这一点,因此Quarkus 也不支持