- ruoyi 4.6
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/):
错误:NoClassDefFoundError: com/alibaba/fastjson/support/spring/PropertyPreFilterscom.alibaba.fastjson2 fastjson2 2.0.8
将 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机械键盘等精美礼品!


