Java家技术论坛

 找回密码
 立即注册

QQ登录

只需一步,快速开始

手机号码,快捷登录

恭喜Java家技术论坛(http://www.javajia.net)已经为数万Java学习者服务超过8年了!积累会员资料超过10000G+
成为本站VIP会员,下载本站10000G+会员资源,购买链接:点击进入购买VIP会员
JavaEE 49期就业班视频教程2019最新 JavaEE 57期 入门到项目实战

最新微服务架构实战160讲教程

Go语言视频零基础入门到精通

Java从菜鸟到大神的学习路线之实战篇

Java开发全终端实战租房项目视频教程

SpringBoot2.X入门到高级使用教程

大数据培训第六期全套视频教程

深度学习(CNN RNN GAN)算法原理

Java亿级流量电商系统视频教程

互联网架构师视频教程

年薪50万Spark2.0从入门到精通

年薪50万!人工智能学习路线教程

年薪50万!大数据从入门到精通学习路线年薪50万!机器学习入门到精通视频教程
查看: 916|回复: 0

[默认分类] 成功解决 org.mybatis.spring.MyBatisSystemException问题!!

[复制链接]
  • TA的每日心情
    开心
    6 天前
  • 签到天数: 9 天

    [LV.3]偶尔看看II

    发表于 2020-8-17 10:21:54 | 显示全部楼层 |阅读模式

    1.   1 org.mybatis.spring.MyBatisSystemException: nested exception is org.apache.ibatis.binding.BindingException: Parameter "couId" not found. Available parameters are [1, 0, param1, param2]
    2.   2     at org.mybatis.spring.MyBatisExceptionTranslator.translateExceptionIfPossible(MyBatisExceptionTranslator.java:73)
    3.   3     at org.mybatis.spring.SqlSessionTemplate$SqlSessionInterceptor.invoke(SqlSessionTemplate.java:364)
    4.   4     at com.sun.proxy.$Proxy15.selectList(Unknown Source)
    5.   5     at org.mybatis.spring.SqlSessionTemplate.selectList(SqlSessionTemplate.java:194)
    6.   6     at org.apache.ibatis.binding.MapperMethod.executeForMany(MapperMethod.java:114)
    7.   7     at org.apache.ibatis.binding.MapperMethod.execute(MapperMethod.java:58)
    8.   8     at org.apache.ibatis.binding.MapperProxy.invoke(MapperProxy.java:43)
    9.   9     at com.sun.proxy.$Proxy17.getSCBycouAndcla(Unknown Source)
    10. 10     at cn.springmvc.serviceiml.SortCourseServiceIml.addSCs(Unknown Source)
    11. 11     at cn.springmvc.controller.SortCourseController.leadinSCs(Unknown Source)
    12. 12     at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    13. 13     at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
    14. 14     at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    15. 15     at java.lang.reflect.Method.invoke(Method.java:606)
    16. 16     at org.springframework.web.bind.annotation.support.HandlerMethodInvoker.invokeHandlerMethod(HandlerMethodInvoker.java:176)
    17. 17     at org.springframework.web.servlet.mvc.annotation.AnnotationMethodHandlerAdapter.invokeHandlerMethod(AnnotationMethodHandlerAdapter.java:440)
    18. 18     at org.springframework.web.servlet.mvc.annotation.AnnotationMethodHandlerAdapter.handle(AnnotationMethodHandlerAdapter.java:428)
    19. 19     at org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:925)
    20. 20     at org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:856)
    21. 21     at org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:936)
    22. 22     at org.springframework.web.servlet.FrameworkServlet.doPost(FrameworkServlet.java:838)
    23. 23     at javax.servlet.http.HttpServlet.service(HttpServlet.java:650)
    24. 24     at org.springframework.web.servlet.FrameworkServlet.service(FrameworkServlet.java:812)
    25. 25     at javax.servlet.http.HttpServlet.service(HttpServlet.java:731)
    26. 26     at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:303)
    27. 27     at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:208)
    28. 28     at org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52)
    29. 29     at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:241)
    30. 30     at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:208)
    31. 31     at org.springframework.web.filter.CharacterEncodingFilter.doFilterInternal(CharacterEncodingFilter.java:88)
    32. 32     at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107)
    33. 33     at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:241)
    34. 34     at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:208)
    35. 35     at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:218)
    36. 36     at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:122)
    37. 37     at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:505)
    38. 38     at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:169)
    39. 39     at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:103)
    40. 40     at org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:956)
    41. 41     at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:116)
    42. 42     at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:442)
    43. 43     at org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:1083)
    44. 44     at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:640)
    45. 45     at org.apache.tomcat.util.net.JIoEndpoint$SocketProcessor.run(JIoEndpoint.java:316)
    46. 46     at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
    47. 47     at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
    48. 48     at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61)
    49. 49     at java.lang.Thread.run(Thread.java:744)
    50. 50 Caused by: org.apache.ibatis.binding.BindingException: Parameter "couId" not found. Available parameters are [1, 0, param1, param2]
    51. 51     at org.apache.ibatis.binding.MapperMethod$ParamMap.get(MapperMethod.java:160)
    52. 52     at org.apache.ibatis.reflection.wrapper.MapWrapper.get(MapWrapper.java:41)
    53. 53     at org.apache.ibatis.reflection.MetaObject.getValue(MetaObject.java:113)
    54. 54     at org.apache.ibatis.scripting.defaults.DefaultParameterHandler.setParameters(DefaultParameterHandler.java:72)
    55. 55     at org.apache.ibatis.executor.statement.PreparedStatementHandler.parameterize(PreparedStatementHandler.java:77)
    56. 56     at org.apache.ibatis.executor.statement.RoutingStatementHandler.parameterize(RoutingStatementHandler.java:58)
    57. 57     at org.apache.ibatis.executor.SimpleExecutor.prepareStatement(SimpleExecutor.java:71)
    58. 58     at org.apache.ibatis.executor.SimpleExecutor.doQuery(SimpleExecutor.java:56)
    59. 59     at org.apache.ibatis.executor.BaseExecutor.queryFromDatabase(BaseExecutor.java:259)
    60. 60     at org.apache.ibatis.executor.BaseExecutor.query(BaseExecutor.java:132)
    61. 61     at org.apache.ibatis.executor.CachingExecutor.query(CachingExecutor.java:105)
    62. 62     at org.apache.ibatis.executor.CachingExecutor.query(CachingExecutor.java:81)
    63. 63     at org.apache.ibatis.session.defaults.DefaultSqlSession.selectList(DefaultSqlSession.java:104)
    64. 64     at org.apache.ibatis.session.defaults.DefaultSqlSession.selectList(DefaultSqlSession.java:98)
    65. 65     at sun.reflect.GeneratedMethodAccessor30.invoke(Unknown Source)
    66. 66     at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    67. 67     at java.lang.reflect.Method.invoke(Method.java:606)
    68. 68     at org.mybatis.spring.SqlSessionTemplate$SqlSessionInterceptor.invoke(SqlSessionTemplate.java:354)
    69. 69     ... 46 more
    70. 70 十月 15, 2017 11:35:33 上午 org.apache.catalina.core.StandardWrapperValve invoke
    71. 71 严重: Servlet.service() for servlet [spring] in context with path [/studentleader] threw exception [Request processing failed; nested exception is org.mybatis.spring.MyBatisSystemException: nested exception is org.apache.ibatis.binding.BindingException: Parameter "couId" not found. Available parameters are [1, 0, param1, param2]] with root cause
    72. 72 org.apache.ibatis.binding.BindingException: Parameter "couId" not found. Available parameters are [1, 0, param1, param2]
    73. 73     at org.apache.ibatis.binding.MapperMethod$ParamMap.get(MapperMethod.java:160)
    74. 74     at org.apache.ibatis.reflection.wrapper.MapWrapper.get(MapWrapper.java:41)
    75. 75     at org.apache.ibatis.reflection.MetaObject.getValue(MetaObject.java:113)
    76. 76     at org.apache.ibatis.scripting.defaults.DefaultParameterHandler.setParameters(DefaultParameterHandler.java:72)
    77. 77     at org.apache.ibatis.executor.statement.PreparedStatementHandler.parameterize(PreparedStatementHandler.java:77)
    78. 78     at org.apache.ibatis.executor.statement.RoutingStatementHandler.parameterize(RoutingStatementHandler.java:58)
    79. 79     at org.apache.ibatis.executor.SimpleExecutor.prepareStatement(SimpleExecutor.java:71)
    80. 80     at org.apache.ibatis.executor.SimpleExecutor.doQuery(SimpleExecutor.java:56)
    81. 81     at org.apache.ibatis.executor.BaseExecutor.queryFromDatabase(BaseExecutor.java:259)
    82. 82     at org.apache.ibatis.executor.BaseExecutor.query(BaseExecutor.java:132)
    83. 83     at org.apache.ibatis.executor.CachingExecutor.query(CachingExecutor.java:105)
    84. 84     at org.apache.ibatis.executor.CachingExecutor.query(CachingExecutor.java:81)
    85. 85     at org.apache.ibatis.session.defaults.DefaultSqlSession.selectList(DefaultSqlSession.java:104)
    86. 86     at org.apache.ibatis.session.defaults.DefaultSqlSession.selectList(DefaultSqlSession.java:98)
    87. 87     at sun.reflect.GeneratedMethodAccessor30.invoke(Unknown Source)
    88. 88     at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    89. 89     at java.lang.reflect.Method.invoke(Method.java:606)
    90. 90     at org.mybatis.spring.SqlSessionTemplate$SqlSessionInterceptor.invoke(SqlSessionTemplate.java:354)
    91. 91     at com.sun.proxy.$Proxy15.selectList(Unknown Source)
    92. 92     at org.mybatis.spring.SqlSessionTemplate.selectList(SqlSessionTemplate.java:194)
    93. 93     at org.apache.ibatis.binding.MapperMethod.executeForMany(MapperMethod.java:114)
    94. 94     at org.apache.ibatis.binding.MapperMethod.execute(MapperMethod.java:58)
    95. 95     at org.apache.ibatis.binding.MapperProxy.invoke(MapperProxy.java:43)
    96. 96     at com.sun.proxy.$Proxy17.getSCBycouAndcla(Unknown Source)
    97. 97     at cn.springmvc.serviceiml.SortCourseServiceIml.addSCs(Unknown Source)
    98. 98     at cn.springmvc.controller.SortCourseController.leadinSCs(Unknown Source)
    99. 99     at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    100. 100     at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
    101. 101     at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    102. 102     at java.lang.reflect.Method.invoke(Method.java:606)
    103. 103     at org.springframework.web.bind.annotation.support.HandlerMethodInvoker.invokeHandlerMethod(HandlerMethodInvoker.java:176)
    104. 104     at org.springframework.web.servlet.mvc.annotation.AnnotationMethodHandlerAdapter.invokeHandlerMethod(AnnotationMethodHandlerAdapter.java:440)
    105. 105     at org.springframework.web.servlet.mvc.annotation.AnnotationMethodHandlerAdapter.handle(AnnotationMethodHandlerAdapter.java:428)
    106. 106     at org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:925)
    107. 107     at org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:856)
    108. 108     at org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:936)
    109. 109     at org.springframework.web.servlet.FrameworkServlet.doPost(FrameworkServlet.java:838)
    110. 110     at javax.servlet.http.HttpServlet.service(HttpServlet.java:650)
    111. 111     at org.springframework.web.servlet.FrameworkServlet.service(FrameworkServlet.java:812)
    112. 112     at javax.servlet.http.HttpServlet.service(HttpServlet.java:731)
    113. 113     at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:303)
    114. 114     at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:208)
    115. 115     at org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52)
    116. 116     at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:241)
    117. 117     at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:208)
    118. 118     at org.springframework.web.filter.CharacterEncodingFilter.doFilterInternal(CharacterEncodingFilter.java:88)
    119. 119     at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107)
    120. 120     at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:241)
    121. 121     at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:208)
    122. 122     at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:218)
    123. 123     at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:122)
    124. 124     at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:505)
    125. 125     at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:169)
    126. 126     at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:103)
    127. 127     at org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:956)
    128. 128     at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:116)
    129. 129     at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:442)
    130. 130     at org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:1083)
    131. 131     at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:640)
    132. 132     at org.apache.tomcat.util.net.JIoEndpoint$SocketProcessor.run(JIoEndpoint.java:316)
    133. 133     at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
    134. 134     at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
    135. 135     at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61)
    136. 136     at java.lang.Thread.run(Thread.java:744)
    复制代码


    今天写项目,写到多个参数从数据库取数据时,一直报这个错,经过查找资料等,终于成功解决,解决前代码为
    DAO层
    修改前:

    1. public  List<SortCourse> getSC(String couId,String classname);  
    复制代码


    mapper.xml
    修改前:

    1. <select id="getSC" parameterType="String" resultType="SortCourse">
    2.     select * from sortcourse where couId=#{couId} and classname=#{classname}
    3. </select>
    复制代码


    因为mapper配置文件中parameterType为String,只能接收一个参数,故将parameterType属性去掉
    则修改第一步:将mapper.xml中将parameterType属性去掉
    修改后:

    1. <select id="getSC"  resultType="SortCourse">
    2.     select * from sortcourse where couId=#{couId} and classname=#{classname}
    3. </select>
    复制代码


    修改第二步:将DAO成代码修改为
    修改后:

    1. public  List<SortCourse> getSC(@Param("couId")String couId,@Param("classname")String classname);
    复制代码


    再导入Param包
    问题成功解决!!
    您需要登录后才可以回帖 登录 | 立即注册

    本版积分规则

    .

    Java家技术论坛 ( 声明:本站资料整理自互联网,用于Java学习者交流学习使用,对资料版权不负任何法律责任,若有侵权请及时联系客服屏蔽删除 )

    GMT+8, 2020-10-25 22:24 , Processed in 0.071065 second(s), 27 queries .

    Powered by Discuz! X3.4

    © 2001-2017 Comsenz Inc.

    快速回复 返回顶部 返回列表