用泛型时,报错提示为:java.lang.Class cannot be cast to java.lang.reflect.parameterizedType

错误原因:

    this.getClass().getGenericSuperclass()返回将是class,this就是当前类的对象,所以一个被泛型化的类是不能被实例化的,只有不被实例化,返回的类型才是ParameterizedType

修改方法一:

 

 

修改方法二:

 <bean id="departmentDao" class="dao.impl.DepartmentDaoImpl">
      
  <property name="hibernateTemplate">
             <ref  bean="hibernateTemplate"/>
         </property>

  </bean>

你可能感兴趣的:(用泛型时,报错提示为:java.lang.Class cannot be cast to java.lang.reflect.parameterizedType)