how to serialize class?

后端 未结 8 1930
自闭症患者
自闭症患者 2021-01-11 19:28

When I insert a List into mongodb, there is a problem:

Exception in thread \"main\" java.lang.IllegalArgumentException: can\'t serialize class mongodb.Person         


        
8条回答
  •  北荒
    北荒 (楼主)
    2021-01-11 20:26

    I got the same exception while working with mongodb. I tried making the problematic class serializable but that didn't fix my problem.

    Following is what worked for me. Extend the class to be a child of BasicDBObject . Of course this works only if the problem is caused by MongoDB.

    extends BasicDBObject 
    

    Original source

    http://techidiocy.com/cant-serialize-class-mongodb-illegal-argument-exception/#comment-1298

提交回复
热议问题