mybatis 通用 mapper 使用时抛出TypeVariableImpl ClassCastException
程序员文章站
2022-07-13 15:59:31
...
Caused by: java.lang.RuntimeException: java.lang.RuntimeException: java.lang.ClassCastException: sun.reflect.generics.reflectiveObjects.TypeVariableImpl cannot be cast to java.lang.Class
at tk.mybatis.mapper.mapperhelper.MapperHelper.setSqlSource(MapperHelper.java:247)
at tk.mybatis.mapper.mapperhelper.MapperHelper.processConfiguration(MapperHelper.java:310)
at tk.mybatis.spring.mapper.MapperFactoryBean.checkDaoConfig(MapperFactoryBean.java:54)
at org.springframework.dao.support.DaoSupport.afterPropertiesSet(DaoSupport.java:44)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:1631)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1568)
... 44 more
Caused by: java.lang.RuntimeException: java.lang.ClassCastException: sun.reflect.generics.reflectiveObjects.TypeVariableImpl cannot be cast to java.lang.Class
at tk.mybatis.mapper.mapperhelper.MapperTemplate.setSqlSource(MapperTemplate.java:246)
at tk.mybatis.mapper.mapperhelper.MapperHelper.setSqlSource(MapperHelper.java:244)
... 49 more
Caused by: java.lang.ClassCastException: sun.reflect.generics.reflectiveObjects.TypeVariableImpl cannot be cast to java.lang.Class
at tk.mybatis.mapper.mapperhelper.MapperTemplate.getEntityClass(MapperTemplate.java:278)
at tk.mybatis.mapper.provider.base.BaseSelectProvider.select(BaseSelectProvider.java:67)
at tk.mybatis.mapper.provider.base.BaseSelectProvider.selectByRowBounds(BaseSelectProvider.java:85)
at sun.reflect.GeneratedMethodAccessor19.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at tk.mybatis.mapper.mapperhelper.MapperTemplate.setSqlSource(MapperTemplate.java:234)
... 50 more
由于把MyMapper放到了mapperScannerConfigurer.setBasePackage的包里面了,MyMapper不能和其他Mapper一样被扫描到