Google Guice 中有一种方便的方法,允许在一次调用中绑定(bind)属性:
Names.bindProperties(binder(), myProperties);
然后可以通过注释注入(inject):
@Inject
@Named("my.properties.server.url")
private String serverUrl;
CDI 中是否有等效的方法(由 Weld 实现)或者更好的方法?
最佳答案
不在核心 CDI 中,但 DeltaSpike 的 ConfigProperty (https://cwiki.apache.org/DeltaSpike/temporary-documentation.html#TemporaryDocumentation-@ConfigProperty) 可能会执行您想要的操作。
关于java - Guice 的 Names.bindProperties(Binder, Properties) 的 CDI (Weld) 等价物是什么?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12314835/