分析:
应该是官方的update策略有变化,3.0以前,使用updateOne,3.0以后使用replaceOne
解决办法:
将updateOne替换为replaceOne即可
完整错误栈:
java.lang.IllegalArgumentException: Invalid BSON field name _id
at org.bson.AbstractBsonWriter.writeName(AbstractBsonWriter.java:494) ~[bson-3.2.2.jar:na]
at org.bson.codecs.DocumentCodec.writeMap(DocumentCodec.java:188) ~[bson-3.2.2.jar:na]
at org.bson.codecs.DocumentCodec.encode(DocumentCodec.java:131) ~[bson-3.2.2.jar:na]
at org.bson.codecs.DocumentCodec.encode(DocumentCodec.java:45) ~[bson-3.2.2.jar:na]
at org.bson.codecs.BsonDocumentWrapperCodec.encode(BsonDocumentWrapperCodec.java:63) ~[bson-3.2.2.jar:na]
at org.bson.codecs.BsonDocumentWrapperCodec.encode(BsonDocumentWrapperCodec.java:29) ~[bson-3.2.2.jar:na]
at com.mongodb.connection.UpdateCommandMessage.writeTheWrites(UpdateCommandMessage.java:84) ~[mongodb-driver-core-3.2.2.jar:na]
at com.mongodb.connection.UpdateCommandMessage.writeTheWrites(Upd