我需要这样简单的东西
@Produces
@Annotated(Licensed.class) //Qualifier
public Set<Class<?>> getLicensedClasses() {
return licensed;
}
但是这不起作用。 CDI 的行为根据文档:
If a producer field type contains a wildcard type parameter the container automatically detects the problem and treats it as a definition error.
片段中的集合包含一堆通过反射获得的类。它是一组使用 @Licensed
注释进行注释的类。
最佳答案
只需删除通配符:
@Produces
@Annotated(Licensed.class) //Qualifier
public Set<Class> getLicensedClasses() {
return licensed;
}
关于java - 具有通配符类型的生产者方法,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22051930/