Reputation: 1441
I'm writing a Quarkus extension (internal usage) and cannot figure how to correctly write the configuration part.
I need to setup a configuration that looks like this, a list of objects containing several configuration properties.
some:
list-of-config:
- prop1: value1
prop2: value2
prop3: value3
- prop1: value4
prop2: value5
prop3: value6
So i was thinking to use @ConfigGroup and a List<> as in the following example:
@ConfigRoot(name = "some", phase = ConfigPhase.BUILD_TIME)
public class MyConfig {
@ConfigItem(defaultValue = "true")
public boolean enabled;
public List<MyGroup> listOfConfig;
@ConfigGroup
public static class MyGroup {
@ConfigItem
public String prop1;
@ConfigItem
public String prop2;
@ConfigItem
public String prop3;
}
}
Unfortunately i get the following exception when starting the application:
SRCFG00013: No Converter registered for class org....MyConfig$MyGroup
@ConfigGroup works pretty well when they are loaded as a single object, but not as a List. I guess this is not really related to config group itself since i also have this error without using config group but simple objects.
Has anyone already tried to use a list of object as configuration for a Quarkus extension ? The official documentation lacks of example about that.
Upvotes: 1
Views: 1027
Reputation: 1441
According to the documentation, any type not being listed or accepting a String parameter as constructor/valueOf/of cannot be used with List or Optional types, except Optional that can also be applied to a configuration group object. Unfortunately, Optional + config group is bugged as mentioned here
So looks like custom objects are not supported, which answer my question. Quarkus is working in adding the use of config mapping for extensions as well, which should solve the issues and add the support for complex types in the future versions (currently 2.1.0 at the time of this question)
Upvotes: 1