代码之家  ›  专栏  ›  技术社区  ›  Boris Pavlović

什么是CDI(焊接)等效于Guice的Names.bindProperties(Binder,Properties)?

  •  1
  • Boris Pavlović  · 技术社区  · 13 年前

    Google Guice中有一个方便的方法,允许在一个调用中绑定属性:

    Names.bindProperties(binder(), myProperties);
    

    然后可通过注释注射:

    @Inject
    @Named("my.properties.server.url")
    private String serverUrl;
    

    CDI中是否有等效的方法(由Weld实现)或更好的方法?

    1 回复  |  直到 13 年前
        1
  •  2
  •   LightGuard    13 年前

    不在核心CDI中,而是DeltaSpike的ConfigProperty(https://cwiki.apache.org/DeltaSpike/temporary-documentation.html#TemporaryDocumentation-@ConfigProperty)可能会做你想做的事。