简体   繁体   中英

What is the best way to configure a bean override of MongoDatastore class in a Grails application that use GORM mongoDB plugin?

In a standard Grails Application that use GORM MongoDB plugin, if you override the class MongoDatastore with a new one (for adding some custom behaviour) eg:

class MyMongoDatastore extends MongoDatastore{ 

      here the override methods and property

}

and you want to configure it to be used by plugin, what's the best approach to use?

In resources.groovy define the bean you're overriding and the class your overriding with:

beans = {
    mongoDatastore(MyMongoDatastore)
}

https://docs.grails.org/latest/guide/spring.html

I've not used mongo before - assuming those names are correct given your example.

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