使用mybatisplus basemapper出现Invalid bound statement (not found)
时间: 2024-05-14 14:11:02 浏览: 24
出现 "Invalid bound statement (not found)" 错误的原因通常是因为 MybatisPlus 的 BaseMapper 找不到指定的 mapper 文件,或者指定的方法名错误导致的。
解决方法如下:
1. 确认 mapper 文件是否存在,以及 mapper 文件中是否有对应的 SQL 语句。
2. 确认 mapper 接口中方法名是否正确,特别是对于自定义的 SQL 语句,需要在注解中指定 SQL 语句的 ID,确保接口方法名与注解中的 ID 一致。
3. 确认 mapper 接口是否正确继承了 BaseMapper 接口,以及是否正确指定了对应的实体类。
如果以上三个问题都没有问题,那么可能是 MybatisPlus 的版本问题或者其他依赖库的问题,需要检查一下相关配置和版本信息。
相关问题
baseMapper报错Invalid bound statement (not found)
根据提供的引用内容,当在mybatis中再次引入mybatis-plus之后,使用公用的BaseMapper时,会出现无法找到sql的报错。这是因为mybatis-plus会覆盖mybatis的默认配置,导致无法找到sql语句。解决方法是在mybatis-plus的配置文件中添加以下配置:
```xml
<configuration>
<plus-config>
<id-type>auto</id-type>
<mapper-locations>
<mapper-location>classpath*:/mapper/*Mapper.xml</mapper-location>
</mapper-locations>
</plus-config>
</configuration>
```
其中,`mapper-locations`指定了mapper文件的位置,需要根据实际情况进行修改。
另外,如果出现类似于“Invalid bound statement (not found)”这样的报错,可能是由于`ResultMap`或`ResultType`没有正确配置导致的。可以检查一下`xxxMapper.xml`文件中的`select`元素是否正确配置了`ResultMap`或`ResultType`。
mybatisplus报Invalid bound statement (not found
根据提供的引用内容,当使用MyBatis Plus时,可能会遇到"Invalid bound statement (not found)"错误。这个错误通常是由于mapper接口和mapper.xml文件没有正确映射导致的。为了解决这个问题,你可以按照以下步骤进行操作:
1. 确保mapper接口和mapper.xml文件的命名规范正确。MyBatis Plus默认使用了一种约定大于配置的方式,即mapper接口的命名应该与mapper.xml文件的命名相同,并且放置在相同的包路径下。
2. 确保mapper接口上的注解与mapper.xml文件中的namespace属性值相同。mapper接口上的注解应该使用@Mapper注解,并且指定namespace属性值为mapper.xml文件的命名空间。
3. 确保mapper接口中的方法名与mapper.xml文件中的statement的id属性值相同。mapper接口中的方法名应该与mapper.xml文件中的statement的id属性值相同,这样才能正确映射。
4. 确保mapper.xml文件中的statement的namespace属性值与mapper接口的全限定名相同。mapper.xml文件中的statement的namespace属性值应该与mapper接口的全限定名相同,这样才能正确映射。
5. 确保mapper.xml文件中的statement的id属性值与mapper接口中的方法名相同。mapper.xml文件中的statement的id属性值应该与mapper接口中的方法名相同,这样才能正确映射。
如果按照以上步骤操作后仍然出现"Invalid bound statement (not found)"错误,可能是由于其他原因导致的。你可以检查mapper.xml文件中是否存在语法错误或者其他配置错误,并确保数据库连接配置正确。
相关推荐
![pdf](https://img-home.csdnimg.cn/images/20210720083512.png)
![pdf](https://img-home.csdnimg.cn/images/20210720083512.png)
![pdf](https://img-home.csdnimg.cn/images/20210720083512.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)