Project scenario:
Mybatis plus version: 3.4.3
create abstract general services for service classes and service implementation classes
eg:
service port: service extends AbstracService<T>
service: serviceimpl extends AbstracServiceImpl<M,T> implements service
Abstract Common Service Interface: AbstracService<T extends xxBaseEntity> extends IService<T>
Abstract Common Service Interface Implementation: AbstracServiceImpl<M extends BaseMapper<T>,T extends xxBaseEntity> extends ServiceImpl<M, T> implements AbstracService<T>
Problem Description.
Startup error message:
Caused by: org.springframework.beans.BeanInstantiationException: Failed to instantiate [cn.xx.xx.xx.service.impl.ServiceImpl]: Constructor threw exception; nested exception is java.lang.ClassCastException: sun.reflect.generics.reflectiveObjects.TypeVariableImpl cannot be cast to java.lang.Class
at org.springframework.beans.BeanUtils.instantiateClass(BeanUtils.java:224)
at org.springframework.beans.factory.support.SimpleInstantiationStrategy.instantiate(SimpleInstantiationStrategy.java:87)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.instantiateBean(AbstractAutowireCapableBeanFactory.java:1326)
… 157 common frames omitted
Caused by: java.lang.ClassCastException: sun.reflect.generics.reflectiveObjects.TypeVariableImpl cannot be cast to java.lang.Class
at com.baomidou.mybatisplus.extension.service.impl.ServiceImpl.currentModelClass(ServiceImpl.java:88)
at com.baomidou.mybatisplus.extension.service.impl.ServiceImpl.(ServiceImpl.java:62)
at cn.lztl.assp.mall.service.impl.AbstractPromotionsServiceImpl.(AbstractPromotionsServiceImpl.java:38)
at cn.lztl.assp.mall.service.impl.ServiceImpl.(SeckillServiceImpl.java:51)
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
at java.lang.reflect.Constructor.newInstance(Constructor.java:423)
at org.springframework.beans.BeanUtils.instantiateClass(BeanUtils.java:211)
… 159 common frames omitted
Solution:
Update mybatis-plus version to version 3.4.3.2 or later.
Introduce dependency com.baomidou.mybatisplus.extension section must be version 3.4.3.2 onwards
Read More:
- [Solved] Tk-Mybatis Error: tk.mybatis.mapper.MapperException:
- MP Error: ‘getBaseMappe ServiceImpl’ clashes [How to Solve]
- Springboot startup error: Field elasticsearchRestTemplate in cn.lili.modules.material.serviceImpl.QrMaterialServiceImpl required a bean of type
- Spring Security Upgrade to Version 5.5.7, 5.6.4 or Above to Startup Error (Version incompatibility)
- [Solved] Java.lang.ClassCastException: [Ljava.lang.Long; cannot be cast to java.util.List
- [Solved] Mapreducer Class Conversion error: java.lang.ClassCastException
- [Solved] Mybatis.generator error: Failed to execute goal org.mybatis.generator:mybatis-generator-maven-plugin:1.3.2
- [Solved] Failed to load class org.slf4j.impl.StaticLoggerBinder
- How to Solve SSM JSON Chinese Messy Code Issue
- [Solved] Jenkins Publish to rancher Error: ERROR: Build step failed with exception java.lang.ClassCastException: class com.
- How to Solve the Primary Key of mybatisPlus Inserted Data is too Large Issue
- [Solved] SpringBoot Startup Error: org.springframework.beans.factory.UnsatisfiedDependencyException Error creating
- [Solved] Mybatis Error: Could not find resource mybatis-conf.xml
- mybatis-plus Common Error and Their Solution
- [Solved] shiro Error: SLF4J: Failed to load class “org.slf4j.impl.StaticLoggerBinder“.
- [2022 New Solution] SLF4J: Failed to load class “org.slf4j.impl.StaticLoggerBinder
- Mybatisenumtypehandler upgrade error of mybatis plus
- JPA multiple-data source startup error: org.springframework.beans.factory.BeanCreationException: Error creating bean with name ‘t
- [Solved] spring boot Startup Error: Error creating bean with name ‘requestMappingHandlerMapping‘ defined in class path
- [Solved] springCloud Startup Error: Error creating bean with name ‘defaultValidator‘ defined in class path resource