寻龙剑侠
发布于 2025-02-18 / 7 阅读
0

[解决]tk.mybatis.mapper.MapperException: 无法获取实体类

报错信息:

tk.mybatis.mapper.MapperException: 无法获取实体类com.changgou.seckill.pojo.SeckillGoods对应的表名!
	at tk.mybatis.mapper.mapperhelper.EntityHelper.getEntityTable(EntityHelper.java:68) ~[mapper-core-1.0.5.jar:na]
	at tk.mybatis.mapper.entity.Example.<init>(Example.java:103) ~[mapper-core-1.0.5.jar:na]
	at tk.mybatis.mapper.entity.Example.<init>(Example.java:88) ~[mapper-core-1.0.5.jar:na]
	at tk.mybatis.mapper.entity.Example.<init>(Example.java:78) ~[mapper-core-1.0.5.jar:na]
	at com.changgou.seckill.task.Task.task(Task.java:30) ~[classes/:na]
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[na:1.8.0_181]
	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[na:1.8.0_181]
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[na:1.8.0_181]
	at java.lang.reflect.Method.invoke(Method.java:498) ~[na:1.8.0_181]

异常原因:

项目微服务中启动类的@MapperScan 注解导错包了

应该是

import tk.mybatis.spring.annotation.MapperScan;
1

不是

import org.mybatis.spring.annotation.MapperScan;
1

解决

导入正确的包

原文地址:解决异常:tk.mybatis.mapper.MapperException: 无法获取实体类-CSDN博客