1

最近、私は grails プロジェクトに取り組んでおり、mysql の他に mongodb を nosql データベースとして使用するつもりです。

mongodb プラグインを追加し、ドメインでテストを行ったところ、うまく機能しました (表示/編集/保存...):

compile ':mongodb:3.0.1'

gmongo プラグインを使用して別の方法を試してください。これは、mongodb の低レベル API を使用する場合 (またはたとえば mapReduce を使用する場合) に役立ちます。

runtime "org.mongodb:mongo-java-driver:2.11.3"
compile "org.mongodb:mongo-java-driver:2.11.3"
runtime "com.gmongo:gmongo:1.3"

簡単なクエリ find() でテストしてみてください。これもうまくいきます

今、私は2つの方法を結合したいのですが、ここにエラーがあります:

| Error 2014-05-13 17:52:07,197 [localhost-startStop-1] ERROR plugins.DefaultGrailsPluginManager  - Error configuring dynamic methods for plugin [mongodb:3.0.1]: com/mongodb/AggregationOptions
Message: com/mongodb/AggregationOptions
    Line | Method
->> 2531 | privateGetDeclaredMethods in java.lang.Class
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 
|   1855 | getDeclaredMethods        in     ''
|     46 | getLocked . . . . . . . . in org.codehaus.groovy.util.LazyReference
|     33 | get                       in     ''
|     98 | createGormStaticApi . . . in org.grails.datastore.gorm.mongo.plugin.support.MongoMethodsConfigurer
|     65 | configure                 in org.grails.datastore.gorm.plugin.support.DynamicMethodsConfigurer
|     49 | configure . . . . . . . . in org.grails.datastore.gorm.mongo.plugin.support.MongoMethodsConfigurer
|     76 | doCall                    in MongodbGrailsPlugin$_closure2
|    262 | run . . . . . . . . . . . in java.util.concurrent.FutureTask
|   1145 | runWorker                 in java.util.concurrent.ThreadPoolExecutor
|    615 | run . . . . . . . . . . . in java.util.concurrent.ThreadPoolExecutor$Worker
^    745 | run                       in java.lang.Thread
Caused by ClassNotFoundException: com.mongodb.AggregationOptions
->>  366 | run                       in java.net.URLClassLoader$1
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 
|    355 | run                       in     ''
|    354 | findClass . . . . . . . . in java.net.URLClassLoader
|    425 | loadClass                 in java.lang.ClassLoader
|   2531 | privateGetDeclaredMethods in java.lang.Class
|   1855 | getDeclaredMethods        in     ''
|     46 | getLocked . . . . . . . . in org.codehaus.groovy.util.LazyReference
|     33 | get                       in     ''
|     98 | createGormStaticApi . . . in org.grails.datastore.gorm.mongo.plugin.support.MongoMethodsConfigurer
|     65 | configure                 in org.grails.datastore.gorm.plugin.support.DynamicMethodsConfigurer
|     49 | configure . . . . . . . . in org.grails.datastore.gorm.mongo.plugin.support.MongoMethodsConfigurer
|     76 | doCall                    in MongodbGrailsPlugin$_closure2
|    262 | run . . . . . . . . . . . in java.util.concurrent.FutureTask
|   1145 | runWorker                 in java.util.concurrent.ThreadPoolExecutor
|    615 | run . . . . . . . . . . . in java.util.concurrent.ThreadPoolExecutor$Worker
^    745 | run                       in java.lang.Thread

実際の直し方がわからない!

4

1 に答える 1

3

Mongodb プラグインは、GORM 機能を備えた GMongo のラッパーです。これらの依存関係を明示的に追加する代わりに、GMongo または下位レベルの API をプラグインから直接使用できます。

それらが含まれているbuild.gradleを見てください。ほとんどの場合、エラーは、両方が同時に使用された場合の依存関係の競合が原因です。

于 2014-05-13T16:10:19.900 に答える