映射文件:

<select id="selectKeyByUserId"  resultMap="Xxx">
        <![CDATA[
        SELECT * FROM 表名1
         where 1=1
            <if test="userId!=0">
            and ID=#{userId,jdbcType=NUMERIC}) 
            </if>
    </select>

dao层

public List<Xxx> selectKeyByUserId(long userId);

Caused by: org.apache.ibatis.reflection.ReflectionException: There is no getter for property named 'userId' in 'class java.lang.Long'
    at org.apache.ibatis.reflection.Reflector.getGetInvoker(Reflector.java:380)
    at org.apache.ibatis.reflection.MetaClass.getGetInvoker(MetaClass.java:170)
    at org.apache.ibatis.reflection.wrapper.BeanWrapper.getBeanProperty(BeanWrapper.java:152)
    at org.apache.ibatis.reflection.wrapper.BeanWrapper.get(BeanWrapper.java:48)
    at org.apache.ibatis.reflection.MetaObject.getValue(MetaObject.java:116)
    at org.apache.ibatis.scripting.xmltags.DynamicContext$ContextMap.get(DynamicContext.java:97)
    at org.apache.ibatis.scripting.xmltags.DynamicContext$ContextAccessor.getProperty(DynamicContext.java:116)
    at org.apache.ibatis.ognl.OgnlRuntime.getProperty(OgnlRuntime.java:1657)
    at org.apache.ibatis.ognl.ASTProperty.getValueBody(ASTProperty.java:92)
    at org.apache.ibatis.ognl.SimpleNode.evaluateGetValueBody(SimpleNode.java:170)
    at org.apache.ibatis.ognl.SimpleNode.getValue(SimpleNode.java:210)
    at org.apache.ibatis.ognl.ASTNotEq.getValueBody(ASTNotEq.java:49)
    at org.apache.ibatis.ognl.SimpleNode.evaluateGetValueBody(SimpleNode.java:170)
    at org.apache.ibatis.ognl.SimpleNode.getValue(SimpleNode.java:210)
    at org.apache.ibatis.ognl.Ognl.getValue(Ognl.java:333)
    at org.apache.ibatis.ognl.Ognl.getValue(Ognl.java:413)
    at org.apache.ibatis.ognl.Ognl.getValue(Ognl.java:395)
    at org.apache.ibatis.scripting.xmltags.OgnlCache.getValue(OgnlCache.java:48)
    at org.apache.ibatis.scripting.xmltags.ExpressionEvaluator.evaluateBoolean(ExpressionEvaluator.java:32)
    at org.apache.ibatis.scripting.xmltags.IfSqlNode.apply(IfSqlNode.java:33)
    at org.apache.ibatis.scripting.xmltags.MixedSqlNode.apply(MixedSqlNode.java:32)
    at org.apache.ibatis.scripting.xmltags.DynamicSqlSource.getBoundSql(DynamicSqlSource.java:40)
    at org.apache.ibatis.mapping.MappedStatement.getBoundSql(MappedStatement.java:278)
    at org.apache.ibatis.executor.CachingExecutor.query(CachingExecutor.java:75)
    at org.apache.ibatis.session.defaults.DefaultSqlSession.selectList(DefaultSqlSession.java:108)
    at org.apache.ibatis.session.defaults.DefaultSqlSession.selectList(DefaultSqlSession.java:102)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:606)
    at org.mybatis.spring.SqlSessionTemplate$SqlSessionInterceptor.invoke(SqlSessionTemplate.java:358)

... 89 more

出现原因
 这里出现的问题是在DAO方法中定义的参数 与 实体中定义的属性不一致 导致的。

解决方案:

dao层加@Param("userId")注解即可

public List<DictItem> selectKeyByUserId(@Param("userId") long userId);

Caused by: org.apache.ibatis.reflection.ReflectionException我碰到的情况,原因不唯一的更多相关文章

  1. Caused by: org.apache.ibatis.reflection.ReflectionException: There is no getter for property named 'zoneId' in 'class java.lang.String'

    本文为博主原创,未经允许不得而转载: 异常展示: dao层定义的接口为: public int getClientTotal(); 在mybatis中的sql为: <select id=&quo ...

  2. Caused by: org.apache.ibatis.reflection.ReflectionException: There is no getter for property named 'company' in 'class java.lang.String'

    Caused by: org.apache.ibatis.reflection.ReflectionException: There is no getter for property named ' ...

  3. mybatis Caused by: org.apache.ibatis.reflection.ReflectionException: Error instantiating class .. with invalid types () or values (). Cause: java.lang.NoSuchMethodException: ...<init>()

    如果有带参数的构造器,编译器不会自动生成无参构造器.当查询需要返回对象时,ORM框架用反射来调用对象的无参构造函数,所以会导致此类异常 public Test(){ }

  4. org.apache.ibatis.reflection.ReflectionException: There is no getter for property named 'parentId' in 'class java.lang.String'

    Caused by: org.apache.ibatis.reflection.ReflectionException: There is no getter for property named ' ...

  5. 【Mybatis】mybatis查询报错org.apache.ibatis.reflection.ReflectionException: There is no getter for property named 'areaName' in 'class java.lang.String'

    mybatis查询报错: Caused by: org.apache.ibatis.reflection.ReflectionException: There is no getter for pro ...

  6. Cause: org.apache.ibatis.reflection.ReflectionException: There is no getter for property named 'empid' in 'class cn.happy.entity.Emp'

    org.apache.ibatis.exceptions.PersistenceException: ### Error querying database.  Cause: org.apache.i ...

  7. Mybatis出错: Cause: org.apache.ibatis.reflection.ReflectionException: Error instantiating class com.cyf.pojo.User with invalid types () or values ()

    org.apache.ibatis.exceptions.PersistenceException: ### Error querying database. Cause: org.apache.ib ...

  8. Error querying database. Cause: org.apache.ibatis.reflection.ReflectionException: There is no getter for property named 'ItemsCustom' in 'class com.pojo.OrderDetailCustom

    再用 junit 测试MyBatis时发现的错误: org.apache.ibatis.exceptions.PersistenceException: ### Error querying data ...

  9. org.apache.ibatis.reflection.ReflectionException

    org.mybatis.spring.MyBatisSystemException: nested exception is org.apache.ibatis.reflection.Reflecti ...

随机推荐

  1. [BZOJ4566][Haoi2016]找相同字符 后缀自动机+dp

    4566: [Haoi2016]找相同字符 Time Limit: 20 Sec  Memory Limit: 256 MBSubmit: 1212  Solved: 694[Submit][Stat ...

  2. AC日记——采花 洛谷 P2056

    采花 思路: 莫队: 代码: #include <bits/stdc++.h> using namespace std; #define maxn 100005 int bel[maxn] ...

  3. CentOS7.5安装下载工具

    ### 视频下载工具 [you-get](https://github.com/soimort/you-get) 和 [youtube-dl](https://github.com/rg3/youtu ...

  4. nginx应用场景,特性,目录结构,常用模块,内置变量,URL和URI,http状态码,配置文件详解

    1.nginx介绍 1丶俄罗斯人开发的,开源www服务软件 2丶软件一共780K 3丶nginx本身是一款静态(html,js,css,jpg等)www软件 4丶静态小文件高并发,同时占用的资源很少, ...

  5. 爬楼梯(LintCode)

    爬楼梯 假设你正在爬楼梯,需要n步你才能到达顶部.但每次你只能爬一步或者两步,你能有多少种不同的方法爬到楼顶部? 样例 比如n=3,中不同的方法 返回 3 用递归又超时了..于是又换了DP,dp并不熟 ...

  6. Maven环境配置及idea建Maven工程

    https://blog.csdn.net/qq_37497322/article/details/78988378

  7. WebService的网络协议

    SOAP协议.XML-RPC以及Hessian 是WebService的主要传输(编码)协议 SOAP即简单对象访问协议(Simple Object Access Protocol),它是用于交换XM ...

  8. 手机上编程,编写android apk

    韩梦飞沙 yue31313 韩亚飞 han_meng_fei_sha  313134555@qq.com C4Droid:在手机上直接编程,然后导出为apk

  9. 【优先队列+贪心】POJ2431-Expedition

    解题方法详见<挑战程序设计竞赛(第二版)>P74-75.注意首先要对加油站以位置为关键字快排,不要遗忘把终点视作一个加油量为0的加油站,否则最终只能到达终点前的加油站. /*优先队列*/ ...

  10. IRC程序学习

    %%聊天的中转站,将{chan,MM,Msg}形式的信息转化为 {mm, MM, Msg}形式 -module(mod_chat_controller). -export([start/3]). -i ...