How to use multiple mongo databases?
Closed this issue · 2 comments
nomadit commented
I have to use two mongo databases.
How can I do?
Last one overwrite the first one.
val app = reactiveWebApplication {
logging {
level = LogLevel.DEBUG
}
configurationProperties<MongoDbConfigProperty>(prefix = "spring.cms.mongodb").apply {
enable(cmsDataConfig(this.uri))
}
configurationProperties<MongoDbConfigProperty>(prefix = "spring.service.mongodb").apply {
enable(serviceDataConfig(this.uri))
}
enable(webConfig)
}
fun main(args: Array<String>) {
app.run()
}
fun cmsDataConfig(uri: String) = configuration {
beans {
bean<CompanyRepository>()
}
reactiveMongodb { this.uri = uri }
}
fun serviceDataConfig(uri: String) = configuration {
beans {
bean<UserRepository>()
}
reactiveMongodb { this.uri = uri }
}