zoukankan      html  css  js  c++  java
  • 在微服务开发的工程中使用mybaits进行查询时,出现了参数无法识别的报错信息:org.apache.ibatis.binding.BindingException: Parameter 'payDate' not found.

    【问题描述】

    2018-06-09 17:33:09.910 ERROR 7424 --- [io-2008-exec-10] o.a.c.c.C.[.[.[/].[dispatcherServlet] : Servlet.service() for servlet [dispatcherServlet] in context with path [] threw exception [Request processing failed; nested exception is org.mybatis.spring.MyBatisSystemException: nested exception is org.apache.ibatis.binding.BindingException: Parameter 'payDate' not found. Available parameters are [arg1, arg0, param1, param2]] with root cause

    org.apache.ibatis.binding.BindingException: Parameter 'payDate' not found. Available parameters are [arg1, arg0, param1, param2]
    at org.apache.ibatis.binding.MapperMethod$ParamMap.get(MapperMethod.java:202) ~[mybatis-3.4.5.jar:3.4.5]
    at org.apache.ibatis.scripting.xmltags.DynamicContext$ContextAccessor.getProperty(DynamicContext.java:115) ~[mybatis-3.4.5.jar:3.4.5]
    at org.apache.ibatis.ognl.OgnlRuntime.getProperty(OgnlRuntime.java:2671) ~[mybatis-3.4.5.jar:3.4.5]
    at org.apache.ibatis.ognl.ASTProperty.getValueBody(ASTProperty.java:114) ~[mybatis-3.4.5.jar:3.4.5]
    at org.apache.ibatis.ognl.SimpleNode.evaluateGetValueBody(SimpleNode.java:212) ~[mybatis-3.4.5.jar:3.4.5]
    at org.apache.ibatis.ognl.SimpleNode.getValue(SimpleNode.java:258) ~[mybatis-3.4.5.jar:3.4.5]
    at org.apache.ibatis.ognl.ASTNotEq.getValueBody(ASTNotEq.java:50) ~[mybatis-3.4.5.jar:3.4.5]
    at org.apache.ibatis.ognl.SimpleNode.evaluateGetValueBody(SimpleNode.java:212) ~[mybatis-3.4.5.jar:3.4.5]
    at org.apache.ibatis.ognl.SimpleNode.getValue(SimpleNode.java:258) ~[mybatis-3.4.5.jar:3.4.5]
    at org.apache.ibatis.ognl.ASTAnd.getValueBody(ASTAnd.java:61) ~[mybatis-3.4.5.jar:3.4.5]

    【原因分析】

    在XxxxMapper.xml文件中,定义的parameterType为"java.util.Map":

    <select id="xxxxxxxx" parameterType="java.util.Map" resultType="com.xxxx.framework.model.xxxx.xxxxxxxxxxxx">

    而在XxxxServiceImpl.java文件中使用XxxxMapper.java文件中的方法进行查询时,传过去的参数不是map集合,而是两个参数;

    【解决方法】

    XxxxServiceImpl.java文件中,调用XxxxMapper类中的查询方法时,需要把相应的参数封装到一个map集合中,然后再传递过去进行查询:

     Map<String, Object> map = new HashMap<String, Object>();

       map.put("userId", userId);
       map.put("payDate", payDate);

     list = xxxxMapper.selectAllByUserIdOrMonth(map);

  • 相关阅读:
    webstorm
    web大文件上传(web应用---SSH框架)
    Webuploader 大文件分片上传
    百度Webuploader 大文件分片上传(.net接收)
    java使用WebUploader做大文件的分块和断点续传
    大文件上传插件webupload插件
    使用Webuploader大文件分片传输
    使用原生Java Web来实现大文件的上传
    Java实现浏览器端大文件分片上传
    怎样使用word2013发布csdn博客
  • 原文地址:https://www.cnblogs.com/heyi-77/p/9165868.html
Copyright © 2011-2022 走看看