sebastiandaschner blog


Inject Quarkus list types with @ConfigProperty

#quarkus friday, august 06, 2021

In a previous post, you’ve seen how to map complex configuration structures with Quarkus using @ConfigMapping. If you have a typed collection, e.g. List<String>, you can also inject these values via @ConfigProperty:

@ApplicationScoped
public class CoffeeShopConfig {

    @ConfigProperty(name = "complex.list")
    List<String> list;

    ...

}

The list can be populated either by a hierarchical config type such as YAML, or via indexed properties:

complex.list[0]=123
complex.list[1]=234
complex.list[2]=456

You will need to use Quarkus 2.1.0.Final or newer for this example.

 

Do you want to learn more about modern development with Quarkus? Then have a look at my upcoming online workshops in October.