简体   繁体   中英

Using Grails with MongoDB

Newbie having a hard time trying to set up mongodb with grails. I know I can't use the plugin install command because its been deprecated. Instead, I must add this to my BuildConfig.groovy:

plugins {
compile ':mongodb:1.2.0' // or whatever is the latest vesrion
}

and then if don't have security set on mongodb do I still have to do this?

grails {
mongo {
    host = "localhost"
    port = 27017
    username = "blah"
    password = "blah"
    databaseName = "foo"
}
}

and that's it? No driver? Is the plugin the driver?

with default MongoDB settings following should be enough


grails {
mongo {
    host = "localhost"
    port = 27017
    databaseName = "foo"
}
}

Another solution I found is that you don't actually even need to have anything in your DataSource.groovy file. I completely made it blank and I am using the java MongoClient object to directly declare the host and port in the constructor of it. Not sure if its the best solution but it does work for me.

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