문제

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.

도움이 되었습니까?

해결책

You have to mark MyItem as a CDI Qualifier, otherwise this annotation will be useless.

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

should do the job.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top