How to read map of config data using Config microprofile?

1,029 views
Skip to first unread message

David Hoffer

unread,
Feb 2, 2021, 6:12:38 PM2/2/21
to Quarkus Development mailing list
I want to be able to specify a list of key/value pairs in my application.yml file and inject using @ConfigProperty but I get a runtime error.

app:
  response-headers:
     header1 : value1
     header2 : value2  
     header3 : value3  
     header4 : value4  

public AppLifecycle(@ConfigProperty(name = "app.response-headers") Map<String, String> responseHeaders) {
this.responseHeaders = responseHeaders;
}

But I get this error:

Caused by: java.lang.IllegalArgumentException: SRCFG00013: No Converter registered for interface java.util.Map
        at io.smallrye.config.SmallRyeConfig.lambda$getConverter$2(SmallRyeConfig.java:289)
        at java.base/java.util.concurrent.ConcurrentHashMap.computeIfAbsent(ConcurrentHashMap.java:1705)
        at io.smallrye.config.SmallRyeConfig.getConverter(SmallRyeConfig.java:286)
        at io.smallrye.config.SmallRyeConfig.getValue(SmallRyeConfig.java:141)
        at io.quarkus.arc.runtime.ConfigBeanCreator.create(ConfigBeanCreator.java:48)

I tried HashMap too.

Do I have to configure SmallRyeConfig to read a Map somehow?

-Dave


Roberto Cortez

unread,
Feb 2, 2021, 6:32:21 PM2/2/21
to dhof...@gmail.com, Quarkus Development mailing list
Hi David,

Config Maps are not supported out of the box yet. I’m working in some prototypes to add support to them.

The YamlConfigSource exposes the source yaml in config value itself, so you could write a Converter for it. Check this out:

Let me know if this works for you.

Cheers,
Roberto

--
You received this message because you are subscribed to the Google Groups "Quarkus Development mailing list" group.
To unsubscribe from this group and stop receiving emails from it, send an email to quarkus-dev...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/quarkus-dev/b53795dc-091e-4099-a98a-cd9d82167f02n%40googlegroups.com.

David Hoffer

unread,
Feb 2, 2021, 7:47:42 PM2/2/21
to Quarkus Development mailing list
Hum, I couldn't follow that.  Also I tried the complex object approach shown on the Quarkus website but could not get that to work either.

I ended up just reading a list and parsing it myself to generate the Map.  Looking forward to seeing your updates to this to support Maps/etc.

app:
  response-headers:
     - header1=value1
     - header2=value2  
     - header3=value3  
     - header4=value4    

-Dave

Georgios Andrianakis

unread,
Feb 3, 2021, 1:51:57 AM2/3/21
to radc...@yahoo.com, David Hoffer, Quarkus Development mailing list
On Wed, Feb 3, 2021 at 1:32 AM 'Roberto Cortez' via Quarkus Development mailing list <quark...@googlegroups.com> wrote:
Hi David,

Config Maps are not supported out of the box yet. I’m working in some prototypes to add support to them.

We do have some support for them in Quarkus as described in https://quarkus.io/guides/kubernetes-config
Reply all
Reply to author
Forward
0 new messages