简体   繁体   中英

How to resolve Caused by: java.lang.ClassNotFoundException: grails.mongodb.MongoEntity

I am trying a very simple code in grails.

I have added below lines in build.gradle file.

compile "org.grails.plugins:mongodb:5.0.5"
compile "org.mongodb:mongodb-driver:3.0.2"
runtime 'org.springframework.data:spring-data-mongodb:1.8.1.RELEASE'

But when I try to execute the code, it is giving me following error at the line of Database connection:

Caused by: java.lang.ClassNotFoundException: grails.mongodb.MongoEntity
    at java.net.URLClassLoader.findClass(URLClassLoader.java:381)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
    at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:331)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
    ... 49 common frames omitted

What is the problem here? Do I need to add another jar in classpath or there is some version problem?

Try with this in your gradle file:

'org.grails:grails-datastore-gorm-mongodb:4.0.7.RELEASE'

You can find more information about that class here: http://grails.github.io/grails-data-mapping/5.0.x/mongodb/api/grails/mongodb/MongoEntity.html

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM