org.apache.ibatis.binding.BindingException: Parameter 'did' not found. Available parameters are [donateId, childId, param1, param2]
时间: 2024-01-14 19:19:10 浏览: 18
org.apache.ibatis.binding.BindingException是MyBatis框架中的异常之一,通常是由于Mapper.xml文件中的参数名与Java接口中的参数名不一致导致的。在这种情况下,MyBatis无法找到正确的参数名,因此会抛出BindingException异常。
针对你提供的引用内容,可以看出是在MyBatis中执行SQL语句时出现了参数名不一致的问题。其中,BindingException异常的信息提示了MyBatis无法找到正确的参数名,而Available parameters则列出了可用的参数名。
解决这个问题的方法是确保Mapper.xml文件中的参数名与Java接口中的参数名一致。如果参数名不一致,可以通过在Mapper.xml文件中使用parameterType属性来指定参数类型,然后在SQL语句中使用#{paramName}来引用参数。
以下是一个示例Mapper.xml文件,其中参数名为did:
```xml
<select id="selectById" parameterType="java.lang.Integer" resultType="com.example.User">
select * from user where id = #{did}
</select>
```
在Java接口中,方法应该如下所示:
```java
public interface UserMapper {
User selectById(Integer did);
}
```
相关问题
org.apache.ibatis.binding.BindingException: Parameter 'id' not found. Available parameters are [map, param1]
org.apache.ibatis.binding.BindingException: Parameter 'id' not found. Available parameters are [map, param1是MyBatis框架的异常信息。这个异常通常是由于MyBatis在执行SQL语句时未能找到指定的参数引起的。根据引用和引用的信息,这个异常的原因可能是在SQL语句中使用了参数'id',但是在实际执行时未传入对应的值。可用的参数有'map'和'param1'。要解决这个异常,您可以检查SQL语句中的参数名是否正确,并确保在执行时传入了正确的参数值。另外,您还可以在MyBatis的settings中使用useActualParamName属性,并在使用Java 8及以上版本时加上-parameters参数,以实现在多参数情况下无需使用@Param注解。<span class="em">1</span><span class="em">2</span><span class="em">3</span>
#### 引用[.reference_title]
- *1* [org.apache.ibatis.binding.BindingException: Parameter ‘id‘ not found.Available parameters are参数...](https://blog.csdn.net/T_Y_F_/article/details/126963292)[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* [mybatis Cause: org.apache.ibatis.binding.BindingException: Parameter 'id' not found. Available param...](https://blog.csdn.net/weixin_42191498/article/details/129153633)[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 ]
org.apache.ibatis.binding.BindingException: Parameter 'params' not found. Available parameters are [Params, param1]
这情况可能是由于对数据库进行操作时有多个参数但是持久层即Dao层中的方法内没有写占位符 @Param("params") 导致的。如果在每个参数前面加上占位符的话就不会出现这种错误。例如,在更新数据时,可以使用注解@Param("params")来指定参数名。在这种情况下,即使有多个参数,也可以正常工作。<span class="em">1</span><span class="em">2</span><span class="em">3</span>
#### 引用[.reference_title]
- *1* *2* [Cause: org.apache.ibatis.binding.BindingException: Parameter ‘xx‘ not found.](https://blog.csdn.net/qq_54141095/article/details/124199713)[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_1"}}] [.reference_item style="max-width: 50%"]
- *3* [org.apache.ibatis.binding.BindingException: Parameter ‘username‘ not found. Available parameters ...](https://blog.csdn.net/qq_30815659/article/details/122016109)[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_1"}}] [.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)
![rar](https://img-home.csdnimg.cn/images/20210720083606.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)