dubbo序列化问题之 Serialized class cn.demo.vo.testDto is not in allow list. Current mode is `STRICT`

文章讲述了在使用ApacheDubbo与Fastjson进行序列化时遇到IllegalArgumentException的问题,原因是序列化的类不在安全白名单中。解决方法是在resource/security目录下创建serialize.allowlist文件,并添加需要序列化的类全路径。实测通过配置已解决问题。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

Caused by: java.lang.IllegalArgumentException: [Serialization Security] Serialized class cn.demo.vo.testDto is not in allow list. Current mode is `STRICT`, will disallow to deserialize it by default. Please add it into security/serialize.allowlist or follow FAQ to configure it.
    at org.apache.dubbo.common.serialize.fastjson2.Fastjson2SecurityManager$Handler.apply(Fastjson2SecurityManager.java:143)
    at com.alibaba.fastjson2.JSONReaderJSONB.readAny(JSONReaderJSONB.java:733)
    at com.alibaba.fastjson2.JSONReaderJSONB.readAny(JSONReaderJSONB.java:930)
    at com.alibaba.fastjson2.reader.ObjectReaderImplObject.readJSONBObject(ObjectReaderImplObject.java:328)
    at com.alibaba.fastjson2.reader.ORG_1_6_DataReturn.readJSONBObject(Unknown Source)
    at com.alibaba.fastjson2.JSONB.parseObject(JSONB.java:540)

出现这种问题解决办法就是在 resource 下新建一个文件夹security 然后在 security 文件夹下新建 serialize.allowlist文件如resource/security/serialize.allowlist

在serialize.allowlist写入允许的类的全路径 例如cn.demo.vo.testDto

实测通过

评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值