sebastiandaschner blog
Inject Quarkus list types with @ConfigProperty
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.
Found the post useful? Subscribe to my newsletter for more free content, tips and tricks on IT & Java: