MongoDB 使用MongoTemplate 更新错误: Collation not supported by wire version: 4
初学mongoDB,使用MongoTemplate 的 updateFirst 踩的一个坑。大致环境:数据库在 Linux虚拟机上mongoDB 3.2.22部分错误信息java.lang.IllegalArgumentException: Collation not supported by wire version: 4at com.mongodb.internal.operation.Ope
·
初学mongoDB,使用MongoTemplate
的 updateFirst
踩的一个坑。
大致环境:
数据库在 Linux虚拟机上 mongoDB 3.2.22
部分错误信息
java.lang.IllegalArgumentException: Collation not supported by wire version: 4
at com.mongodb.internal.operation.OperationHelper.validateCollationAndWriteConcern(OperationHelper.java:134)
at com.mongodb.internal.operation.OperationHelper.validateWriteRequestCollations(OperationHelper.java:174)
at com.mongodb.internal.operation.OperationHelper.validateWriteRequests(OperationHelper.java:180)
at com.mongodb.internal.operation.MixedBulkWriteOperation.validateWriteRequestsAndReleaseConnectionIfError(MixedBulkWriteOperation.java:518)
at com.mongodb.internal.operation.MixedBulkWriteOperation.access$000(MixedBulkWriteOperation.java:71)
at com.mongodb.internal.operation.MixedBulkWriteOperation$1.call(MixedBulkWriteOperation.java:183)
at com.mongodb.internal.operation.MixedBulkWriteOperation$1.call(MixedBulkWriteOperation.java:180)
at com.mongodb.internal.operation.OperationHelper.withReleasableConnection(OperationHelper.java:500)
at com.mongodb.internal.operation.MixedBulkWriteOperation.execute(MixedBulkWriteOperation.java:180)
at com.mongodb.internal.operation.MixedBulkWriteOperation.execute(MixedBulkWriteOperation.java:71)
at com.mongodb.client.internal.MongoClientDelegate$DelegateOperationExecutor.execute(MongoClientDelegate.java:207)
at com.mongodb.client.internal.MongoCollectionImpl.executeSingleWriteRequest(MongoCollectionImpl.java:1008)
at com.mongodb.client.internal.MongoCollectionImpl.executeUpdate(MongoCollectionImpl.java:992)
at com.mongodb.client.internal.MongoCollectionImpl.updateOne(MongoCollectionImpl.java:577)
at org.springframework.data.mongodb.core.MongoTemplate.lambda$doUpdate$19(MongoTemplate.java:1652)
at org.springframework.data.mongodb.core.MongoTemplate.execute(MongoTemplate.java:566)
at org.springframework.data.mongodb.core.MongoTemplate.doUpdate(MongoTemplate.java:1625)
at org.springframework.data.mongodb.core.MongoTemplate.updateFirst(MongoTemplate.java:1556)
at com.service.Impl.UserServiceImpl.deposit(UserServiceImpl.java:65)
at com.web.controller.UserController.deposit(UserController.java:63)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
错误的代码块
从报错信息和追溯了一下抛出错误的源码来看错误的原因是因为wire (mongoDB的网络协议)的版本问题,因此在网上找了一天关于网络协议的信息,最后都没有得到解决,就在我快绝望的时候,我尝试将User.class
从mongoTemplate.updateFirest的构造函数中去除,结果错误就解决了。
更多推荐
已为社区贡献4条内容
所有评论(0)