问题

这个noValue一定存在,但是报错。

场景就是存在并发的情况下,尤其是在服务刚刚启动的时候,就会发生这个异常。

但是很不幸,mybatis 3.4.1之前,用的 OGNL都是由这个问题。

分析

3.4.1 之前的版本的 OgnlRuntime,这里,第三个参数传0,则永远都是null。

public static final Object getMethodValue(OgnlContext context, Object target, String propertyName, boolean checkAccessAndExistence) throws OgnlException, IllegalAccessException, NoSuchMethodException, IntrospectionException {
Object result = null;
Method m = getGetMethod(context, target == null ? null : target.getClass(), propertyName);
if (m == null) {
m = getReadMethod(target == null ? null : target.getClass(), propertyName, 0);
}

3.4.1 以及以后的版本:

 public static final Object getMethodValue(OgnlContext context, Object target, String propertyName, boolean checkAccessAndExistence) throws OgnlException, IllegalAccessException, NoSuchMethodException, IntrospectionException {
Object result = null;
Method m = getGetMethod(context, target == null ? null : target.getClass(), propertyName);
if (m == null) {
m = getReadMethod(target == null ? null : target.getClass(), propertyName, (Class[])null);
}

显然 getReadMethod 这个地方的实现已经完全发生改变。



getGetMethod 存在 并发问题,线程不安全。

解决 Mybatis报错org.apache.ibatis.ognl.NoSuchPropertyException: XXXCriteria$Criterion.noValue的更多相关文章

  1. 已解决: 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 ...

  2. Maven项目使用mybatis报错 org.apache.ibatis.binding.BindingException: Invalid bound statement (not found):

    maven项目使用mybatis时,找不到mapper文件(.xml) 错误信息提示: 项目可以正常运行,但是在有请求到达服务器时(有访问数据库的请求),会出现报错!! 错误原因: mybatis没有 ...

  3. MyBatis 报错org.apache.ibatis.session.defaults.DefaultSqlSessionFactory.openSessionFromDataSource

    报错如下: org.apache.ibatis.exceptions.PersistenceException: ### Error opening session. Cause: java.lang ...

  4. 报错org.apache.ibatis.binding.BindingException: Type interface com.atguigu.mybatis.bean.dao.EmployeeMapper is not known to the MapperRegistry.

    报错org.apache.ibatis.binding.BindingException: Type interface com.atguigu.mybatis.bean.dao.EmployeeMa ...

  5. maven 项目报错org.apache.ibatis.binding.BindingException: Invalid bound statement (not found)解决

    idea在使用maven构建的项目中使用mybatis时报错org.apache.ibatis.binding.BindingException: Invalid bound statement (n ...

  6. 解决Mybatis 报错Invalid bound statement (not found)

    解决Mybatis 报错Invalid bound statement (not found) 出现此错误的原因 1.xml文件不存在 2.xml文件和mapper没有映射上 namespace指定映 ...

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

  8. mybatis plus 报错 org.apache.ibatis.binding.BindingException: Invalid bound statement (not found)

    org.apache.ibatis.binding.BindingException: Invalid bound statement (not found) 少了个范型

  9. maven项目 报错 org.apache.ibatis.binding.BindingException: Invalid bound statement (not found):

    ssm的项目如果在mapper.xml  mapper接口 配置没问题的情况下  项目依然报org.apache.ibatis.binding.BindingException: Invalid bo ...

随机推荐

  1. SpringBootSecurity学习(02)网页版登陆配置类代替默认配置

    增加Security配置类 前面演示了一个简单的登录入门例子,使用springboot-security默认的配置实现,虽然非常简单,但是基本实现了登录功能.不过在生产环境下,显然不能仅仅使用如此简单 ...

  2. 每个人都要学的图片压缩终极奥义,有效解决 Android 程序 OOM

    # 由来 在我们编写 Android 程序的时候,几乎永远逃避不了图片压缩的难题.除了应用图标之外,我们所要显示的图片基本上只有两个来源: 来自网络下载 本地相册中加载 不管是网上下载下来的也好,还是 ...

  3. ThinkPHP5实现定时任务

    ThinkPHP5实现定时任务 最近使用ThinkPHP5做了个项目,项目中需要定时任务的功能,感觉有必要分享下 TP5做定时任务使用到command.php的 步骤如下: 1.配置command.p ...

  4. SpringBoot自定义异常,优雅解决业务逻辑中的错误

    概要 你是不是在为业务逻辑中出现的异常弄的焦头烂额,常常在后台报错,前端却无法提示错误内容,导致用户体验极差?比如下单失败,前端只能提示下单失败,但是却不知道为什么失败,是库存不足,还是余额不足,亦或 ...

  5. [PHP] php, apache, VS Code安装与配置

    1. 下载

  6. 写了那么多年 Java 代码,终于 debug 到 JVM 了

    继上篇文章 原创 | 全网最新最简单的 openjdk13 代码编译 之后,我们有了自己编译后的 jdk 和 hotspot,如下图所示.接下来就来干一番事情. 搭建调试环境 1.下载 CLion 软 ...

  7. IBM MQ8.0常用操作

    一.创建队列管理器 1.创建队列管理器QM1:crtmqm -q QM1 2.删除队列管理器QM1:dltmqm QM1 3.启动队列管理器QM1:strmqm QM1 4.停止队列管理器QM1:en ...

  8. Java8新特性时间日期库DateTime API及示例

    Java8新特性的功能已经更新了不少篇幅了,今天重点讲解时间日期库中DateTime相关处理.同样的,如果你现在依旧在项目中使用传统Date.Calendar和SimpleDateFormat等API ...

  9. 从输入URL到页面渲染完成 -戈多编程

    1.输入URL地址 2.浏览器根据域名查询IP地址 3.浏览器发送HTTP请求到web服务器 4.服务器返回一个永久重定向响应 5.浏览器会跟踪重定向地址 6.服务器处理请求 7.服务器返回一个HTM ...

  10. redis系列之------数据库

    前言 当我们在Redis数据库中set一个KV的时候,这个KV保存在哪里?如果我们get的时候,又从哪里get出来.时间复杂度,空间复杂的等等,怎么优化等等一系列问题. 服务器中的数据库 Redis服 ...