分享web开发知识

注册/登录|最近发布|今日推荐

主页 IT知识网页技术软件开发前端开发代码编程运营维护技术分享教程案例
当前位置:首页 > 运营维护

解决 Mybatis报错org.apache.ibatis.ognl.NoSuchPropertyException: XXXCriteria$Criterion.noValue

发布时间:2023-09-06 02:34责任编辑:彭小芳关键词:apache

问题

这个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

原文地址:https://www.cnblogs.com/slankka/p/10478536.html

知识推荐

我的编程学习网——分享web前端后端开发技术知识。 垃圾信息处理邮箱 tousu563@163.com 网站地图
icp备案号 闽ICP备2023006418号-8 不良信息举报平台 互联网安全管理备案 Copyright 2023 www.wodecom.cn All Rights Reserved