zoukankan      html  css  js  c++  java
  • 解决 Mybatis报错org.apache.ibatis.ognl.NoSuchPropertyException: XXXCriteria$Criterion.noValue

    问题

    这个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 存在 并发问题,线程不安全。

  • 相关阅读:
    树莓派使用MJPG-Streamer实现网络监控
    树莓派USB摄像头与camera模块对比
    机器人教程
    win10开始菜单打不开怎么办 win菜单键没反应解决办法
    solr查询语法
    Substance 6 设置 watermark(水印)
    在SWING里嵌入SWT的组件
    solr 5.5.1安装并配置中文分词IKAnalyzer
    [简单]docx4j常用方法小结
    Java串口通信详解
  • 原文地址:https://www.cnblogs.com/slankka/p/10478536.html
Copyright © 2011-2022 走看看