环境: Java JDK11 + SpringBoot 2.1.6.RELEASE + Mybaits-Plus 3.3.2
使用Mybatis-Plus中碰到的问题
- 问题1
“org.apache.ibatis.binding.BindingException: Invalid bound statement (not found): com.product.mapper.ProductMapper.insert“
-
解决办法
查错发现问题出现在Mapper层,在引用BaseMapper的时候,没有指明实体类是哪一个
错误示范:
正确示范(Product是我的pojo类):
-
问题2
java.lang.IllegalStateException: Unable to find a @SpringBootConfiguration, you need to use @ContextConfiguration or @SpringBootTest(classes=…) with your test
-
解决方法
测试类进行测试的时候出现的问题,解决办法有两种
1. 将测试类 @SpringBootTest 中加入 classes = 启动类.class
(此处 ProductApplication 是我项目的启动类)
2.将test下面创建包名和和启动类 一样