Enterprise Java
Inject Quarkus list types with @ConfigProperty
Inject Quarkus list types with @ConfigProperty
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.
Published on Java Code Geeks with permission by Sebastian Daschner, partner at our JCG program. See the original article here: Inject Quarkus list types with @ConfigProperty Opinions expressed by Java Code Geeks contributors are their own. |