scala中使用fastjson把对象转换成json报错,提示:method toJSONString in class JSON of type (x$1: Any)String
scala中使用fastjson把对象转换成json报错,提示:
        ambiguous reference to overloaded definition,
both method toJSONString in class JSON of type (x: Any, x: com.alibaba.fastjson.serializer.SerializerFeature*)String
and  method toJSONString in class JSON of type (x: Any)String
match argument types (com.kafka.producer.UserPoJo)
    JSON.toJSONString(user)发布于:2年前 (2024-01-25) IP属地:未知
        2 个回答
            
        这是因为scala语言中不能匹配java的多态,所以这里我们可以写成:
这样就不会报错了。
JSON.toJSONString(user,new SerializeConfig(true))这样就不会报错了。
发布于:2年前 (2024-01-25) IP属地:未知
    
            我来回答
        
        
            您需要 登录 后回答此问题!
            
                    