問題
??單元測試時(shí),遇到以下報(bào)錯(cuò):文章來源:http://www.zghlxwxcb.cn/news/detail-533417.html
com.baomidou.mybatisplus.core.exceptions.MybatisPlusException: error: can not execute. because can not find cache of TableInfo for entity!
at com.baomidou.mybatisplus.core.toolkit.ExceptionUtils.mpe(ExceptionUtils.java:49)
at com.baomidou.mybatisplus.core.toolkit.Assert.isTrue(Assert.java:38)
at com.baomidou.mybatisplus.core.toolkit.Assert.notNull(Assert.java:72)
at com.baomidou.mybatisplus.extension.service.impl.ServiceImpl.saveOrUpdateBatch(ServiceImpl.java:174)
at com.baomidou.mybatisplus.extension.service.IService.saveOrUpdateBatch(IService.java:91)
... ....
解決方案
在測試類中,添加mybatis的初始化構(gòu)建文章來源地址http://www.zghlxwxcb.cn/news/detail-533417.html
/**
* before設(shè)置
*/
@Before
public void setUp() {
//構(gòu)建mybatis
TableInfoHelper.initTableInfo(new MapperBuilderAssistant(new MybatisConfiguration(), ""), UserEntity.class);
}
到了這里,關(guān)于SpringBoot——單元測試error: can not execute. because can not find cache of TableInfo for entity!的文章就介紹完了。如果您還想了解更多內(nèi)容,請?jiān)谟疑辖撬阉鱐OY模板網(wǎng)以前的文章或繼續(xù)瀏覽下面的相關(guān)文章,希望大家以后多多支持TOY模板網(wǎng)!