1

I have the following classes:

public class MyMap extends HashMap {
   public MyMap () { }
   some more methods...
}


@SessionScoped
public ProducerClass implements Serializable {
   @Produces @MyItem  HashMap<A,B> produceItems () { }
}

@Named 
public ConsumerClass {
  @Inject @MyItem HashMap<A,B> property;
}

@Retention(RUNTIME)
public @interface MyItem {
}

I get the error ambiguous injection point at property for MyMap and HashMap form ConsumerClass.

How can it be ? I thought that the injection class is unique given through @MyItem annotation.

4

1 回答 1

5

您必须将MyItem标记为 CDI Qualifier,否则此注释将无用。

@Qualifier
@Retention(RUNTIME)
public @interface MyItem {
}

应该做的工作。

于 2013-09-11T21:37:15.627 回答