在这个类的声明中
public class ProductTypeDaoImpl extends GenericDaoImpl implements ProductTypeDao
您正在使用
GenericDaoImpl和
ProductTypeDao作为原始类型。首先阅读为什么不应该使用它们。
您正在使用原始类型的事实在这里引起问题
ParameterizedType genericSuperclass = (ParameterizedType) getClass().getGenericSuperclass();
自以来,在哪里
getGenericSuperclass()将返回
Class实例
GenericDaoImpl
public class ProductTypeDaoImpl extends GenericDaoImpl implements ProductTypeDao
未参数化,因此不是
ParameterizedType。然后强制转换失败。
解决方案是在类声明中参数化这两种类型。从您的代码中并不能立即看出这些类型参数应该是什么,但
GenericTypeDao应该采用
ProductTypeDomain
public class ProductTypeDaoImpl extends GenericDaoImpl<ProductTypeDomain> implements ProductTypeDao
并且您的接口
ProductTypeDao可能应该声明为
public interface ProductTypeDao extends GenericDao<ProductTypeDomain> {


