org.apache.ibatis.binding.BindingException: Invalid bound statement (not found): com.bookstore.dao.BookMapper.selectAll
时间: 2023-10-15 11:31:14 浏览: 46
这个异常通常是由于 MyBatis 没有找到指定的 SQL 语句引起的。根据你提供的信息,看起来你在 `com.bookstore.dao.BookMapper` 接口中没有定义名为 `selectAll` 的 SQL 语句。
请确保在 `BookMapper.xml`(或者是你使用注解的话,可以是 `@Select` 注解所标注的方法)中定义了名为 `selectAll` 的 SQL 语句。例如,在 `BookMapper.xml` 文件中添加如下代码:
```xml
<select id="selectAll" resultType="com.bookstore.model.Book">
SELECT * FROM books
</select>
```
这样,MyBatis 就能找到并映射名为 `selectAll` 的 SQL 语句了。记得根据你的实际情况修改 SQL 语句和结果类型。
相关问题
org.apache.ibatis.binding.BindingException: Invalid bound statement (not found):selectlist
`org.apache.ibatis.binding.BindingException: Invalid bound statement (not found)`异常通常是因为MyBatis找不到映射文件中的某个语句引起的。这个异常通常有两种情况:
1.映射文件中没有定义该语句。
2.映射文件中定义了该语句,但是语句的ID与调用时的ID不匹配。
解决这个异常的方法如下:
1.检查映射文件中是否定义了该语句,如果没有定义,则需要添加该语句的定义。
2.检查调用时的ID是否与映射文件中定义的ID匹配,如果不匹配,则需要修改调用时的ID。
下面是一个例子,演示了如何解决`org.apache.ibatis.binding.BindingException: Invalid bound statement (not found)`异常:
```java
// 映射文件中的语句定义
<select id="selectList" resultType="com.team.news.model.NewsDetail">
select * from news_detail
</select>
// 调用时的语句ID与映射文件中的语句ID不匹配,会抛出异常
List<NewsDetail> newsList = sqlSession.selectList("com.team.news.mapper.NewsDetailMapper.selectByExample");
// 修改调用时的语句ID,使其与映射文件中的语句ID匹配
List<NewsDetail> newsList = sqlSession.selectList("com.team.news.mapper.NewsDetailMapper.selectList");
```
org.apache.ibatis.binding.BindingException: Invalidbound statement (not found)
当出现org.apache.ibatis.binding.BindingException: Invalid bound statement (not found)错误时,通常是因为MyBatis无法找到对应的SQL语句映射。
要解决这个问题,可以按照以下步骤进行排查:
1. 首先,检查一下你的Mapper.xml文件中是否存在与该错误相关的SQL语句映射。确保SQL语句的id与Mapper接口中对应方法的名称一致。<span class="em">1</span><span class="em">2</span><span class="em">3</span>
#### 引用[.reference_title]
- *1* [mybatis访问报错:org.apache.ibatis.binding.BindingException: Invalid bound statement (not found)...](https://blog.csdn.net/weixin_34402408/article/details/86024348)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v93^chatsearchT3_2"}}] [.reference_item style="max-width: 50%"]
- *2* *3* [【报错解决】org.apache.ibatis.binding.BindingException: Invalid bound statement (not found)](https://blog.csdn.net/qq_50914927/article/details/127091350)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v93^chatsearchT3_2"}}] [.reference_item style="max-width: 50%"]
[ .reference_list ]
相关推荐
![png](https://img-home.csdnimg.cn/images/20210720083516.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)