mybatisplus报错 can not find lambda cache for this entity
mybatisplus+JUnit & Mocktio+单元测试报错
文章共200字 · 阅读需要大约1分钟
一键AI生成摘要,助你高效阅读
问答
·
项目中使用JUnit & Mocktio进行单元测试,如果代码中使用LambdaQueryWrapper进行条件构造,在DO类中有类似@TableId、@TableLogic等注解,在执行单元测试时会报错 MybatisPlusException: can not find lambda cache for this property [] of entity []
假如一个test类里面使用到的方法多的话,可以使用before注解让这行代码在测试类中所有方法执行之前就添加。在junit 5.x中,@Before主键被@BeforeEach所替代。
@BeforeEach
public void initTable() {
TableInfoHelper.initTableInfo(new MapperBuilderAssistant(new MybatisConfiguration(), ""), Xxx.class);
}
或者
@Before
public void init() {
TableInfoHelper.initTableInfo(new MapperBuilderAssistant(new MybatisConfiguration(), ""), Xxx.class);
}
具体分析参考:
can not find lambda cache for this property [XXX] of entity [com.XXX.XXX]_V六块腹肌的程序员的博客-CSDN博客
更多推荐
已为社区贡献1条内容
所有评论(0)