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?

War es hilfreich?

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
scroll top