私は依存性注入にGuiceを使用しています。私はちょっと混乱しています。Guiceの名前付き注射の使用
com.google.inject.name.Named
と(JSR 330?)の2種類のアノテーションがあります。
私はjavax.inject.*
に頼りたいです。コードサンプル:
import javax.inject.Inject;
import javax.inject.Named;
public class MyClass
{
@Inject
@Named("APrefix_CustomerTypeProvider")
private CustomerTypeProvider customerTypeProvider;
}
私は次の行を持っていることがあります。
bind(CustomerTypeProvider.class).annotatedWith(...).toProvider(CustomerTypeProviderProvider.class);
質問:私はドットがどこに私が入れすべきか興味が?私はcom.google.inject.name.Names.named("APrefix_CustomerTypeProvider")
のようなものを期待していますが、これはcom.google.inject.name.Named
を返す一方、私はjavax.inject
のものが必要です。
CustomerTypeProviderProvider.class.getAnnotation(javax.inject.Named.class)
CustomerTypeProviderProvider
(愚かな名前、旧来の問題を無視する)は注釈付けされていないため、うまく適合しません。