问题
I'm trying to upgrade my mongodb plugin from 2.0.1 to 3.0.3. However I keep getting the following error:
java.lang.NoClassDefFoundError: com/mongodb/AggregationOptions
at java.lang.Class.getDeclaredMethods0(Native Method)
at java.lang.Class.privateGetDeclaredMethods(Class.java:2531)
at java.lang.Class.getDeclaredMethods(Class.java:1855)
at org.codehaus.groovy.reflection.CachedClass$3$1.run(CachedClass.java:84)
at java.security.AccessController.doPrivileged(Native Method)
at org.codehaus.groovy.reflection.CachedClass$3.initValue(CachedClass.java:81)
at org.codehaus.groovy.reflection.CachedClass$3.initValue(CachedClass.java:79)
at org.codehaus.groovy.util.LazyReference.getLocked(LazyReference.java:46)
at org.codehaus.groovy.util.LazyReference.get(LazyReference.java:33)
at org.codehaus.groovy.reflection.CachedClass.getMethods(CachedClass.java:250)
at groovy.lang.MetaClassImpl.populateMethods(MetaClassImpl.java:343)
at groovy.lang.MetaClassImpl.fillMethodIndex(MetaClassImpl.java:293)
at groovy.lang.MetaClassImpl.initialize(MetaClassImpl.java:3048)
at groovy.lang.ExpandoMetaClass.initialize(ExpandoMetaClass.java:483)
at org.codehaus.groovy.reflection.ClassInfo.getMetaClassUnderLock(Cl
...
I've tried changing the version of the plugin to 3.0.2 but the error persists.
UPDATE:
I'm on Grails 2.3.11
.
I've tried including the plugin with specifying no dependencies and also copy pasting the dependencies from my past configuration which is:
dependencies {
runtime "org.mongodb:mongo-java-driver:2.11.4"
compile "org.mongodb:mongo-java-driver:2.11.4"
runtime "com.gmongo:gmongo:1.2"
}
and
plugins {
...
compile(':mongodb:2.0.1') {
excludes 'mongo-java-driver', 'gmongo'
}
回答1:
Update your BuildConfig a bit:
compile ":mongodb:3.0.2"
Don't specify any other mongo related dependencies and don't exclude mongo-java-driver
or gmongo
. Also, if you are using mongeez plugin then you have to exclude the java driver.
compile (":mongeez:0.2.3") {
excludes("mongo-java-driver")
}
回答2:
changing dependencies to:
runtime "org.mongodb:mongo-java-driver:2.12.3"
compile "org.mongodb:mongo-java-driver:2.12.3"
works
来源:https://stackoverflow.com/questions/29278975/cant-run-grails-app-with-mongodb-plugin-version-3-0-3