Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to use multiple mongo databases? #292

Closed
nomadit opened this issue Jul 21, 2020 · 2 comments
Closed

How to use multiple mongo databases? #292

nomadit opened this issue Jul 21, 2020 · 2 comments
Labels
type: enhancement A general enhancement

Comments

@nomadit
Copy link

nomadit commented Jul 21, 2020

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 }
}
@sdeleuze sdeleuze added this to the 0.5.0 milestone Aug 30, 2020
@sdeleuze sdeleuze added status: pending-design-work Needs design work before any code can be developed type: enhancement A general enhancement labels Jan 8, 2021
@fteychene
Copy link
Contributor

The overriding is due to how beans are registered during initialization.
One way to make it work is to provide a way for naming beans.
There is another issue to work on this specific topic #359

@sdeleuze
Copy link
Collaborator

sdeleuze commented Apr 7, 2021

This will be covered by #359 so I close this issue.

@sdeleuze sdeleuze closed this as completed Apr 7, 2021
@sdeleuze sdeleuze removed the status: pending-design-work Needs design work before any code can be developed label Apr 7, 2021
@sdeleuze sdeleuze removed this from the 0.5.0 milestone Apr 7, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type: enhancement A general enhancement
Projects
None yet
Development

No branches or pull requests

3 participants