我希望能够在同一应用程序中使用Hibernate和MongoDB,定义2个数据源。我在BuildConfig中添加了以下内容:
compile ":mongodb:1.3.1"
当我尝试执行grails编译时,我得到以下信息:
| Installing zip mongodb-1.3.1.zip...
| Installing zip mongodb-1.3.1.zip....
| Installing zip mongodb-1.3.1.zip.....
| Installed plugin mongodb-1.3.1
| Installed plugin mongodb-1.3.1.
| Installed plugin mongodb-1.3.1..
| Installed plugin mongodb-1.3.1...
| Installed plugin mongodb-1.3.1....
| Installed plugin mongodb-1.3.1.....
| Error Fatal error during compilation org.springframework.beans.factory.BeanDefinitionStoreException: Failed to read candidate component class: URL [jar:file:/Users/gdboling/.grails/ivy-cache/org.grails/grails-hibernate/jars/grails-hibernate-2.2.4.jar!/org/codehaus/groovy/grails/compiler/gorm/GormTransformer.class]; nested exception is java.lang.NoClassDefFoundError: org/springframework/core/type/classreading/AnnotationMetadataReadingVisitor (Use --stacktrace to see the full trace)
MongoDB插件的文档说这是可能的,但是我不确定为什么仅在将MongoDB插件添加到BuildConfig之后就收到此编译错误。
更新:
经过更多的谷歌搜索之后,看来与mongodb插件尝试使用的版本与我们的Grails版本(2.2.4)使用的版本可能存在版本冲突。不太清楚如何解决或跟踪此问题。
最佳答案
在邮件列表中找到以下内容:
http://grails.1312388.n4.nabble.com/Upgrade-from-MongoDB-plugin-1-3-0-to-1-3-1-compile-error-td4651482.html
从MongoDB插件版本1.3.1降级到1.3.0,现在一切正常。
关于hibernate - 使用MongoDB和Hibernate的Grails,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20012721/