Closed SoerenHenning closed 1 year ago
Unfortunately, the documentation is incorrect. The format value of server.reasons=200=OK;201=Created
is only intended to be used with org.eclipse.microprofile.config.inject.ConfigProperty#defaultValue
, since it can only accept a String
value.
In regular config sources, like properties files, a Map
is expressed like map.path.key=value
. Updating your example:
SmallRyeConfig config = new SmallRyeConfigBuilder()
.withSources(new PropertiesConfigSource(Map.of(
"server.reasons.OK", "200",
"server.reasons.CREATED", "201"), "", 100))
.build();
System.out.println(config.getValues("server.reasons", String.class, Integer.class));
This works.
I'm sorry for the inconvenience. I'll update the docs.
Alright, thank you! :)
Hi, I am trying to reproduce the example of the Map Support example from the documentation. However, I get an NoSuchElementException when trying to read a configuration value as Map. I use version
3.2.1
and the programmatical access without any CDI involved in my setup.In more detail, I performed the following steps:
to my
META-INF/microprofile-config.properties
file.server.reasons
by setting an environment variableSERVER.REASONS
but I got the same exception.