使用Mabatis-plus新增数据出错
@RunWith(SpringJUnit4ClassRunner.class)
@ContextConfiguration(locations = {"classpath:applicationContext.xml"})
public class TestMapperTest extends TestCase {
@Resource
private TestMapper testMapper;
@Test
public void tsetInstant() {
Test2 test2 = new Test2();
test2.setContent("xxxxx");
testMapper.insert(test2);
}
}Caused by: java.lang.ClassCastException: com.baomidou.mybatisplus.extension.plugins.inner.PaginationInnerInterceptor cannot be cast to org.apache.ibatis.plugin.Interceptor at com.baomidou.mybatisplus.core.MybatisXMLConfigBuilder.pluginElement(MybatisXMLConfigBuilder.java:190) at com.baomidou.mybatisplus.core.MybatisXMLConfigBuilder.parseConfiguration(MybatisXMLConfigBuilder.java:112) ... 69 more Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'sessionFactory' defined in class path resource [applicationContext.xml]: Invocation of init method failed; nested exception is org.springframework.core.NestedIOException: Failed to parse config resource: class path resource [mybatis-config.xml]; nested exception is org.apache.ibatis.builder.BuilderException: Error parsing SQL Mapper Configuration. Cause: java.lang.ClassCastException: com.baomidou.mybatisplus.extension.plugins.inner.PaginationInnerInterceptor cannot be cast to org.apache.ibatis.plugin.Interceptor
40
收起
正在回答 回答被采纳积分+1
1回答
好帮手慕小小
2022-07-11 13:43:49
同学你好
1、建议检查下相关jar是否导入成功。例如:
<!-- MyBatis-Plus依赖 --> <dependency> <groupId>com.baomidou</groupId> <artifactId>mybatis-plus</artifactId> <version>3.3.2</version> </dependency>

2、applicationContext.xml中是否更改配置SqlSessionFactory实现类
<bean id="sessionFactory" class="com.baomidou.mybatisplus.extension.spring.MybatisSqlSessionFactoryBean">

祝学习愉快~
2023版Java工程师
- 参与学习 人
- 提交作业 8788 份
- 解答问题 9886 个
综合就业常年第一,编程排行常年霸榜,北上广深月薪过万! 不需要基础,无需脱产即可学习,只要你有梦想,想高薪! 全新升级:技术栈升级(包含VUE3.0,ES6,Git)+项目升级(前后端联调与功能升级)
了解课程




恭喜解决一个难题,获得1积分~
来为老师/同学的回答评分吧
0 星