0

使用不同版本的 mongodb java 客户端时出现更新错误。我运行了依赖报告,发现只有 1 个 jar 用于 mongdb java 驱动程序。请指导为什么会出现此错误,我正在尝试通过 GORM 更新域对象。

dependencies {
 runtime "org.mongodb:mongo-java-driver:2.9.0"
}


 plugins {
compile (":mongodb:1.3.0"){
    excludes "mongo-java-driver";
}
}


Message: ACKNOWLEDGED
Line | Method
    ->>  646 | doInDB                  in                 
org.grails.datastore.mapping.mongo.engine.MongoEntityPersister$5

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 
|    616 | updateEntry             in 
org.grails.datastore.mapping.mongo.engine.MongoEntityPersister
|     78 | updateEntry . . . . . . in     ''
|    846 | run                     in       
org.grails.datastore.mapping.engine.NativeEntryEntityPersister$2
|     33 | executePendingOperation in  
org.grails.datastore.mapping.core.impl.PendingOperationExecution
|    364 | flushPendingOperations  in org.grails.datastore.mapping.core.AbstractSession
|    343 | flushPendingUpdates . . in     ''
|    263 | flush                   in     ''
|    126 | flush . . . . . . . . . in org.grails.datastore.mapping.mongo.MongoSession
4

1 回答 1

1

WriteConcern.ACKNOWLEDGED 仅在 MongoDB Java 驱动程序 2.10 及更高版本中可用。您要么需要更新 Mongo 版本:

dependencies {
 runtime "org.mongodb:mongo-java-driver:2.10.0"
}

或者您需要在此处删除对 mongo 驱动程序的排除:

compile (":mongodb:1.3.0"){
    excludes "mongo-java-driver";
}

并将其替换为:

compile ":mongodb:1.3.0"

如果您采用第二个选项,这将使用 2.11 版本的 Mongo Java 驱动程序,这正是该插件代码所期望的。使用早于 2.11 的驱动程序版本可能会导致此类问题。

于 2013-10-23T16:44:19.200 回答