一、异常的内容

调用的映射方法:

    @Insert("insert into user_role(userId,roleId) values(#{userId},#{id})")void saveUserWithRole( String userId,  String id) throws MyException;

出现的异常:

Caused by: org.apache.ibatis.binding.BindingException: Parameter 'userId' not found. Available parameters are [arg1, arg0, param1, param2]at org.apache.ibatis.binding.MapperMethod$ParamMap.get(MapperMethod.java:202)at org.apache.ibatis.reflection.wrapper.MapWrapper.get(MapWrapper.java:45)at org.apache.ibatis.reflection.MetaObject.getValue(MetaObject.java:122)at org.apache.ibatis.scripting.defaults.DefaultParameterHandler.setParameters(DefaultParameterHandler.java:79)at org.apache.ibatis.executor.statement.PreparedStatementHandler.parameterize(PreparedStatementHandler.java:93)at org.apache.ibatis.executor.statement.RoutingStatementHandler.parameterize(RoutingStatementHandler.java:64)at org.apache.ibatis.executor.SimpleExecutor.prepareStatement(SimpleExecutor.java:86)at org.apache.ibatis.executor.SimpleExecutor.doUpdate(SimpleExecutor.java:49)at org.apache.ibatis.executor.BaseExecutor.update(BaseExecutor.java:117)at org.apache.ibatis.executor.CachingExecutor.update(CachingExecutor.java:76)at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)at java.lang.reflect.Method.invoke(Method.java:498)at org.apache.ibatis.plugin.Plugin.invoke(Plugin.java:63)at com.sun.proxy.$Proxy121.update(Unknown Source)

二、解决方案

这是由于出入多参,sql语句中的取参结果成了这样 userId.userId,userId.roleId,所以需要定义一下sql语句中引入的参数对应方法中的哪个参数,修改如下:

 //用mybatis提供的@Param注解,定义sql语句中的对应参数@Insert("insert into user_role(userId,roleId) values(#{userId},#{otherroleId})")void saveUserWithRole( @Param("userId")String userId,  @Param("otherroleId")String id) throws MyException;

关于mybatis的Parameter ‘userid‘ not found. Available parameters are [arg1, arg0, param1, param2]的解决方案相关推荐

  1. Parameter 'userid' not found. Available parameters are [arg1, arg0, param1, param2]的解决办法

    HTTP Status 500 – Internal Server Error Type 异常报告 消息 Request processing failed; nested exception is ...

  2. Mybatis 报错`Parameter '0' not found. Available parameters are [arg1, arg0, param1, param2]`

    1.异常信息: Parameter '0' not found. Available parameters are [arg1, arg0, param1, param2] 这是因为mybatis的M ...

  3. 错误:Parameter ‘0‘ not found.Available parameters are [arg1, arg0, param1, param2]的解决方法

    错误:Parameter '0' not found.Available parameters are [arg1, arg0, param1, param2]的解决方法 参考文章: (1)错误:Pa ...

  4. Parameter ‘username‘ not found. Available parameters are [arg1, arg0, param1, param2] 绑定参数异常

    出现绑定异常 绑定参数username找不到,这是一个知识点的补漏,这篇文章相信对你肯定有所帮助! org.apache.ibatis.binding.BindingException: Parame ...

  5. idea运行报错Parameter ‘name‘ not found. Available parameters are [arg1, arg0, param1, param2]

    Parameter 'name' not found. Available parameters are [arg1, arg0, param1, param2] 出现问题: 在mapper或者dao ...

  6. java 传入多个参数时报Parameter 'XXX' not found. Available parameters are [arg1, arg0, param1,... 解决方案...

    @Select("SELECT id FROM ae_post ORDER BY id DESC LIMIT #{page},#{size}")List<Post> g ...

  7. Parameter ‘ew‘ not found. Available parameters are [wrapper, page, param1, param2]

    Parameter 'ew' not found. Available parameters are [wrapper, page, param1, param2] 源码 Impl类 @Overrid ...

  8. Mybatis错误:Parameter 'XXX' not found. Available parameters are [1, 0, param1, param2]

     这个问题我遇到了两次,我也不太清楚到底是什么原因,先贴出解决方案吧 修改前的代码: [java] view plaincopy @Select("select * from fruit ...

  9. Parameter 'userName' not found. Available parameters are [1, 0, param1, param2]

    Mapper接口的方法的参数没有加:@Param("xxx")注解,或者是xxx写不对 转载于:https://www.cnblogs.com/linliquan/p/109871 ...

最新文章

  1. 都有Python了,还要什么编译器!
  2. 对于session序列化跟session的钝化与活化的粗浅理解
  3. python教程:apscheduler模块使用教程
  4. C++实现bellman ford贝尔曼-福特算法(最短路径)(附完整源码)
  5. LiveVideoStackCon深圳 - 洞察多媒体技术生态趋势与机会
  6. matlab 粘连分割代码,【求助】图像中粘连字符切分代码,求注释!!!
  7. ERPS(Ethernet Ring Protection Switching):以太网多环保护技术
  8. 大话移动通信(第2版)!(文末赠书福利)
  9. 2010年中考英语写作高分指导
  10. App Store 受欢迎榜单(美国区)-分析出未来方向
  11. Excel如何制作直方图与正态分布曲线
  12. 人工智能应用场景分析
  13. 牙医管家牙科软件APP功能-“看牙无忧”口腔分期功能介绍
  14. iOS比较常用的第三方及实例(不断更新中)
  15. yamaha php mt8评测,诶哟这个盒子不错哟,NUC 8i5BEK简单开箱+评测(更新完毕)
  16. 图文深度解析Linux内存碎片整理实现机制以及源码
  17. IO流 | IO流的应用举例
  18. 深度分析这一年「AI大咖」,最重要的跳槽原因是……
  19. DevTools 无法加载来源映射:无法加载 http://localhost:8082/axios.min.map 的解决方法
  20. Linux命令行技巧——使用目录栈进行导航

热门文章

  1. mysql 两个日期加减_mysql日期加减运算
  2. 浏览器中输入的URL网址的意义-概述
  3. Jenkins安全插件——Arachni扫描器介绍
  4. 洛谷:Apples prologue/苹果和虫子(c语言)
  5. 计算机毕业设计Java-ssmNBA论坛系统源码+系统+数据库+lw文档
  6. 基于stm32cubeMX的stm32f103c8t6的HAL库开发的智能小车------小车接线和材料准备
  7. 字节跳动,华为,阿里巴巴,小米,腾讯 2021大厂面试经历系列之初、中、高级测试工程师面试题汇总(附答案)
  8. 2015如何通过QQ群零成本赚钱?
  9. vim快捷键运行Java、Python程序
  10. js 实现倒计时(短信验证码倒计时)