@Service
public class ImformationModelEsServiceImpl extends BaseEsService<ImformationModuleEsEntity{
}
问:如何获取ImformationModelEsServiceImpl类中的泛型ImformationModuleEsEntity?
答:
Type genericSuperclass = this.getClass().getGenericSuperclass();
if (genericSuperclass instanceof ParameterizedType){
ParameterizedType parameterizedType = (ParameterizedType) genericSuperclass;
Type[] actualTypeArguments = parameterizedType.getActualTypeArguments();
for (Type actualTypeArgument : actualTypeArguments) {
System.out.println(actualTypeArgument);
}
}
注意:本文归作者所有,未经作者允许,不得转载