栏目分类:
子分类:
返回
名师互学网用户登录
快速导航关闭
当前搜索
当前分类
子分类
实用工具
热门搜索
名师互学网 > IT > 软件开发 > 后端开发 > Java

【若依(ruoyi)】NoClassDefFoundError: com/alibaba/fastjson/support/spring/PropertyPreFilters

Java 更新时间: 发布时间: IT归档 最新发布 模块sitemap 名妆网 法律咨询 聚返吧 英语巴士网 伯小乐 网商动力

【若依(ruoyi)】NoClassDefFoundError: com/alibaba/fastjson/support/spring/PropertyPreFilters

前言
  • ruoyi 4.6
将 fastjson 升级从1.2.75 到 2.0.8

maven坐标(https://repo1.maven.org/maven2/com/alibaba/fastjson/):


    com.alibaba
    fastjson
    1.2.75


    com.alibaba
    fastjson
    2.0.8

fastjson 1.x的项目名称为:fastjson
fastjson 2.x的项目名称为:fastjson2

fastjson 自2.0之后的版本,仅为兼容 fastjons2。

fastjson2 相较于 fastjson 已做较大改动,老项目无法直接使用fastjson2 。为了解决这个问题,fastjson 2.x提供兼容 fastjson2,使老项目可以平滑升级到2.x。

fastjson2的maven坐标(https://repo1.maven.org/maven2/com/alibaba/fastjson2/fastjson2/):


    com.alibaba.fastjson2
    fastjson2
    2.0.8

错误:NoClassDefFoundError: com/alibaba/fastjson/support/spring/PropertyPreFilters

将 fastjson 升级从1.2.75 到 2.0.8后,报错:NoClassDefFoundError: com/alibaba/fastjson/support/spring/PropertyPreFilters。

错误原因

fastjson 2.x 的 SerializeFilter 与 1.x不一样了。

解决办法
    private void setRequestValue(SysOperLog operLog) throws Exception
    {
        Map map = ServletUtils.getRequest().getParameterMap();
        if (StringUtils.isNotEmpty(map))
        {
            PropertyPreFilters.MySimplePropertyPreFilter excludefilter = new PropertyPreFilters().addFilter();
            excludefilter.addExcludes(EXCLUDE_PROPERTIES);
            String params = JSONObject.toJSONString(map, excludefilter);
            operLog.setOperParam(StringUtils.substring(params, 0, 2000));
        }
    }

改为

    private void setRequestValue(SysOperLog operLog) throws Exception
    {
        Map map = ServletUtils.getRequest().getParameterMap();
        if (StringUtils.isNotEmpty(map))
        {
            SimplePropertyPreFilter serializeFilter = new SimplePropertyPreFilter();
            serializeFilter.getExcludes().addAll(Arrays.asList(EXCLUDE_PROPERTIES));
            String params = JSONObject.toJSONString(map, serializeFilter);
            operLog.setOperParam(StringUtils.substring(params, 0, 2000));
        }
    }
暑期编程PK赛 得CSDN机械键盘等精美礼品!
转载请注明:文章转载自 www.mshxw.com
本文地址:https://www.mshxw.com/it/1017538.html
我们一直用心在做
关于我们 文章归档 网站地图 联系我们

版权所有 (c)2021-2022 MSHXW.COM

ICP备案号:晋ICP备2021003244-6号