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);

  • 相关阅读:
    lerna管理前端packages的最佳实践
    理解Python闭包,这应该是最好的例子
    Maven 初学+http://mvnrepository.com/
    逆向工程,调试Hello World !程序(更新中)
    github设置仓库可见性 私人仓库设置他人协作/可见
    flink 1.9.0 编译:flink-fs-hadoop-shaded 找不到
    中通消息平台 Kafka 顺序消费线程模型的实践与优化
    以友盟+U-Push为例,深度解读消息推送的筛选架构解决方案应用与实践
    idea新建spring boot项目使用maven引入依赖失败,pom.xml文件中project标签报错
    RabbitMQ (十二) 消息确认机制
  • 原文地址:https://www.cnblogs.com/heyi-77/p/9165868.html
Copyright © 2011-2022 走看看