美文网首页
mybatis方法执行报错org.apache.ibatis.b

mybatis方法执行报错org.apache.ibatis.b

作者: 吉他钢琴曲 | 来源:发表于2021-01-20 10:24 被阅读0次

使用mybatis,运行时报错

2021-01-19 17:41:02.877 ERROR 20544 --- [io-10031-exec-1] 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 'car' not found. Available parameters are [arg1, arg0, param1, param2]] with root cause

org.apache.ibatis.binding.BindingException: Parameter 'car' not found. Available parameters are [arg1, arg0, param1, param2]
    at org.apache.ibatis.binding.MapperMethod$ParamMap.get(MapperMethod.java:204)
    at org.apache.ibatis.scripting.xmltags.DynamicContext$ContextAccessor.getProperty(DynamicContext.java:115)
    at org.apache.ibatis.ognl.OgnlRuntime.getProperty(OgnlRuntime.java:2685)
    at org.apache.ibatis.ognl.ASTProperty.getValueBody(ASTProperty.java:114)
    at org.apache.ibatis.ognl.SimpleNode.evaluateGetValueBody(SimpleNode.java:212)
    at org.apache.ibatis.ognl.SimpleNode.getValue(SimpleNode.java:258)
    at org.apache.ibatis.ognl.ASTChain.getValueBody(ASTChain.java:141)
    at org.apache.ibatis.ognl.SimpleNode.evaluateGetValueBody(SimpleNode.java:212)
    at org.apache.ibatis.ognl.SimpleNode.getValue(SimpleNode.java:258)
    at org.apache.ibatis.ognl.ASTNotEq.getValueBody(ASTNotEq.java:50)
    at org.apache.ibatis.ognl.SimpleNode.evaluateGetValueBody(SimpleNode.java:212)
    at org.apache.ibatis.ognl.SimpleNode.getValue(SimpleNode.java:258)
    at org.apache.ibatis.ognl.Ognl.getValue(Ognl.java:470)
    at org.apache.ibatis.ognl.Ognl.getValue(Ognl.java:434)
    at org.apache.ibatis.scripting.xmltags.OgnlCache.getValue(OgnlCache.java:44)
    at org.apache.ibatis.scripting.xmltags.ExpressionEvaluator.evaluateBoolean(ExpressionEvaluator.java:32)
    at org.apache.ibatis.scripting.xmltags.IfSqlNode.apply(IfSqlNode.java:34)
    at org.apache.ibatis.scripting.xmltags.MixedSqlNode.apply(MixedSqlNode.java:33)
    at org.apache.ibatis.scripting.xmltags.DynamicSqlSource.getBoundSql(DynamicSqlSource.java:41)
    at org.apache.ibatis.mapping.MappedStatement.getBoundSql(MappedStatement.java:292)
    at com.github.pagehelper.PageInterceptor.intercept(PageInterceptor.java:82)

检查代码

// 查询车辆信息
    List<CarInfoDTO> selectDTOByEntity(@Param("car") CarInfo carInfo, @Param("orderByStr") String orderByStr);

发现 @Param 注解引用的是org.springframework.data.repository.query.Param,导致多参数情况下mybatis 无法判断参数名称
应该引用 org.apache.ibatis.annotations.Param

相关文章

网友评论

      本文标题:mybatis方法执行报错org.apache.ibatis.b

      本文链接:https://www.haomeiwen.com/subject/yvohzktx.html