What is CDI (Weld) equivalent for Guice's Names.bindProperties(Binder, Properties)?
-
30-06-2021 - |
Frage
There's a convenient method in Google Guice which allows binding of properties in one call:
Names.bindProperties(binder(), myProperties);
which are then injectable by annotation:
@Inject
@Named("my.properties.server.url")
private String serverUrl;
Is there an equivalent method in CDI (implemented by Weld) or something even better?
Lösung
Not in core CDI, but DeltaSpike's ConfigProperty (https://cwiki.apache.org/DeltaSpike/temporary-documentation.html#TemporaryDocumentation-@ConfigProperty) will probably do what you want.
Lizenziert unter: CC-BY-SA mit Zuschreibung
Nicht verbunden mit StackOverflow