本文为博主原创,未经允许不得而转载:

异常展示:

dao层定义的接口为:

public int getClientTotal();

在mybatis中的sql为:

<select id="getClientTotal" parameterType="String" resultType="Integer">
SELECT COUNT(*) AS oldNum FROM tbl__client_info
<where>
<if test="zoneId!=null and !&quot;&quot;.equals(zoneId.trim())">
and zone1Id = #{zoneId}
</if>
</where>
</select>

在运行的时候控制台报一下异常:

Caused by: org.apache.ibatis.reflection.ReflectionException: There is no getter for property named 'zoneId' in 'class java.lang.String'
at org.apache.ibatis.reflection.Reflector.getGetInvoker(Reflector.java:422) ~[mybatis-3.4.2.jar:3.4.2]
at org.apache.ibatis.reflection.MetaClass.getGetInvoker(MetaClass.java:164) ~[mybatis-3.4.2.jar:3.4.2]
at org.apache.ibatis.reflection.wrapper.BeanWrapper.getBeanProperty(BeanWrapper.java:162) ~[mybatis-3.4.2.jar:3.4.2]
at org.apache.ibatis.reflection.wrapper.BeanWrapper.get(BeanWrapper.java:49) ~[mybatis-3.4.2.jar:3.4.2]
at org.apache.ibatis.reflection.MetaObject.getValue(MetaObject.java:122) ~[mybatis-3.4.2.jar:3.4.2]
at org.apache.ibatis.scripting.xmltags.DynamicContext$ContextMap.get(DynamicContext.java:94) ~[mybatis-3.4.2.jar:3.4.2]
at org.apache.ibatis.scripting.xmltags.DynamicContext$ContextAccessor.getProperty(DynamicContext.java:108) ~[mybatis-3.4.2.jar:3.4.2]
at org.apache.ibatis.ognl.OgnlRuntime.getProperty(OgnlRuntime.java:2666) ~[mybatis-3.4.2.jar:3.4.2]
at org.apache.ibatis.ognl.ASTProperty.getValueBody(ASTProperty.java:114) ~[mybatis-3.4.2.jar:3.4.2]
at org.apache.ibatis.ognl.SimpleNode.evaluateGetValueBody(SimpleNode.java:212) ~[mybatis-3.4.2.jar:3.4.2]
at org.apache.ibatis.ognl.SimpleNode.getValue(SimpleNode.java:258) ~[mybatis-3.4.2.jar:3.4.2]
at org.apache.ibatis.ognl.ASTNotEq.getValueBody(ASTNotEq.java:50) ~[mybatis-3.4.2.jar:3.4.2]
at org.apache.ibatis.ognl.SimpleNode.evaluateGetValueBody(SimpleNode.java:212) ~[mybatis-3.4.2.jar:3.4.2]
at org.apache.ibatis.ognl.SimpleNode.getValue(SimpleNode.java:258) ~[mybatis-3.4.2.jar:3.4.2]
at org.apache.ibatis.ognl.ASTAnd.getValueBody(ASTAnd.java:61) ~[mybatis-3.4.2.jar:3.4.2]
at org.apache.ibatis.ognl.SimpleNode.evaluateGetValueBody(SimpleNode.java:212) ~[mybatis-3.4.2.jar:3.4.2]
at org.apache.ibatis.ognl.SimpleNode.getValue(SimpleNode.java:258) ~[mybatis-3.4.2.jar:3.4.2]
at org.apache.ibatis.ognl.Ognl.getValue(Ognl.java:467) ~[mybatis-3.4.2.jar:3.4.2]
at org.apache.ibatis.ognl.Ognl.getValue(Ognl.java:431) ~[mybatis-3.4.2.jar:3.4.2]
at org.apache.ibatis.scripting.xmltags.OgnlCache.getValue(OgnlCache.java:44) ~[mybatis-3.4.2.jar:3.4.2]
at org.apache.ibatis.scripting.xmltags.ExpressionEvaluator.evaluateBoolean(ExpressionEvaluator.java:32) ~[mybatis-3.4.2.jar:3.4.2]
at org.apache.ibatis.scripting.xmltags.IfSqlNode.apply(IfSqlNode.java:34) ~[mybatis-3.4.2.jar:3.4.2]
at org.apache.ibatis.scripting.xmltags.MixedSqlNode.apply(MixedSqlNode.java:33) ~[mybatis-3.4.2.jar:3.4.2]
at org.apache.ibatis.scripting.xmltags.TrimSqlNode.apply(TrimSqlNode.java:55) ~[mybatis-3.4.2.jar:3.4.2]
at org.apache.ibatis.scripting.xmltags.MixedSqlNode.apply(MixedSqlNode.java:33) ~[mybatis-3.4.2.jar:3.4.2]
at org.apache.ibatis.scripting.xmltags.DynamicSqlSource.getBoundSql(DynamicSqlSource.java:41) ~[mybatis-3.4.2.jar:3.4.2]
at org.apache.ibatis.mapping.MappedStatement.getBoundSql(MappedStatement.java:292) ~[mybatis-3.4.2.jar:3.4.2]
at org.apache.ibatis.executor.CachingExecutor.query(CachingExecutor.java:81) ~[mybatis-3.4.2.jar:3.4.2]
at org.apache.ibatis.session.defaults.DefaultSqlSession.selectList(DefaultSqlSession.java:148) ~[mybatis-3.4.2.jar:3.4.2]
at org.apache.ibatis.session.defaults.DefaultSqlSession.selectList(DefaultSqlSession.java:141) ~[mybatis-3.4.2.jar:3.4.2]
at org.apache.ibatis.session.defaults.DefaultSqlSession.selectOne(DefaultSqlSession.java:77) ~[mybatis-3.4.2.jar:3.4.2]
at sun.reflect.GeneratedMethodAccessor90.invoke(Unknown Source) ~[na:na]
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[na:1.8.0_121]
at java.lang.reflect.Method.invoke(Method.java:498) ~[na:1.8.0_121]
at org.mybatis.spring.SqlSessionTemplate$SqlSessionInterceptor.invoke(SqlSessionTemplate.java:433) ~[mybatis-spring-1.3.1.jar:1.3.1]
... 52 common frames omitted

错误分析及解决方法:

错误原因:在于sql中test="zoneId!=null and !&quot;&quot;.equals(zoneId.trim())"条件判断,在mybatis解析sql的时候,会将test中的属性解析为bean的

属性,mybatis解析获取值的时候通过getProperty的方法获取,同理,当sql从数据库查到数值,将属性值赋值给属性的时候通过setProperty方法。由于

mybatis将接口中的String参数解析为bean属性,就需要有set,get方法,set,get方法一般都写在实体类中,接口中的属性可以通过@Param()注解来实现

set,get方法。

修改方法:

public int getClientTotal(@Param("zoneId")String zoneId);

然后重新启动就ok了。

Caused by: org.apache.ibatis.reflection.ReflectionException: There is no getter for property named 'zoneId' in 'class java.lang.String'的更多相关文章

  1. 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 ' ...

  2. 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 ' ...

  3. 【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 ...

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

    mybatis接口 List<String> getUsedCate(String time); 配置文件 <select id="getUsedCate" pa ...

  5. Mybatis笔记四:nested exception is org.apache.ibatis.reflection.ReflectionException: There is no getter for property named 'id' in 'class java.lang.String'

    错误异常:nested exception is org.apache.ibatis.reflection.ReflectionException: There is no getter for pr ...

  6. 已解决: mybatis报错 org.apache.ibatis.reflection.ReflectionException: There is no getter for property named 'xxx' in 'class java.lang.String'

    最近在练习MyBatis时 进行姓名的模糊查询时候出现 org.apache.ibatis.exceptions.PersistenceException: ### Error querying da ...

  7. nested exception is org.apache.ibatis.reflection.ReflectionException: There is no getter for property named 'enterpriseId' in 'class java.lang.String'

    错误信息: nested exception is org.apache.ibatis.reflection.ReflectionException: There is no getter for p ...

  8. org.mybatis.spring.MyBatisSystemException: nested exception is org.apache.ibatis.reflection.ReflectionException: There is no getter for property named 'socialCode' in 'class java.lang.String'

    异常: org.mybatis.spring.MyBatisSystemException: nested exception is org.apache.ibatis.reflection.Refl ...

  9. MyBatis映射,抛出Cause: org.apache.ibatis.reflection.ReflectionException: There is no getter for property named 'oid' in 'class java.lang.String'

    原因在于: 在MyBatis中使用动态语句的判断时,传入的参数(parameterType)为Java基本数据类型,获取的结果(resultType)为JavaBean对象,此时就会抛出该异常,此时可 ...

随机推荐

  1. 【2017-03-02】C#集合,结构体,枚举

    集合 集合与数组的区别 数组:同一类型,固定长度 集合:不同类型,不固定长度 使用集合前需要:     引用命名空间:using System.Collections; 1.普通集合 定义: Arra ...

  2. Spring cglib 初始化 ExceptionInInitializerError,new Enhancer() 异常

    解决办法:更换 spring-cglib-repack-*.*.jar 包 java.lang.ExceptionInInitializerError at org.springframework.a ...

  3. mongoDB3.4的sharding集群搭建及JavaAPI的简易使用

    第一部分 在搭建mongoDB之前,我们要考虑几个小问题: 1.我们搭建集群的目的是什么?是多备份提高容错和系统可用性还是横向拓展存储大规模数据还是两者兼有? 如果是为了多备份那么选择replicat ...

  4. GIT库代码管理规范

    GIT库代码管理规范 一. 规范要求 1. 每个项目建立单独的GIT库.每个GIT库包括两条线,命名规则如下: 开发线(测试):项目名称_DEV 生产线(正式):项目名称 2. 每条线只允许增量不允许 ...

  5. [转载]FlipClock.js时钟,计数,3D翻转插件

    1.FlipClock.js能够自动定义计数,时钟的翻牌效果,调用简单,下面简单记录下用法 2.官网地址:http://www.flipclockjs.com/ 3.调用2个文件 <link h ...

  6. vue 加载更多

        <template>   <div>     <ul>       <li v-for="item in articles"> ...

  7. a标签(普通标签如span)没有disabled属性 ,怎样利用js实现该属性

    a标签以及其她普通标签没有disabled属性,要想实现类似input框属性disabled可以通过css样式设置pointer-events的值来设定: <!DOCTYPE html> ...

  8. sql注入(转载)

    1.使用firefox浏览器(安装一个firebug插件)登录http://192.168.204.132/dvwa/login.php页面,使用admin/password 2.打开firebug工 ...

  9. reids非关系性数据库

     1.Redis环境配置 下载安装地址: https://github.com/MicrosoftArchive/redis/releases 解压文件到指定的目录,D:\ChromeCoreDown ...

  10. Python网络编程,粘包、分包问题的解决

    tcp编程中的粘包.分包问题的解决: 参考:https://blog.csdn.net/yannanxiu/article/details/52096465 服务端: #!/bin/env pytho ...