Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
@EnableMongoRepositories(
basePackages = ["com.example.multimongo.data.external"],
mongoTemplateRef = "externalMongoTemplate")
@Configuration
class ExternalDatabaseConfiguration : ExtraMongoConfiguration() {
@Value("\${additional-db.external.uri:}")
override val uri: String? = null
@Value("\${additional-db.external.host:}")
override val host: String? = null
@Value("\${additional-db.external.port:0}")
override val port: Int? = 0
@Value("\${additional-db.external.database:}")
override val database: String? = null
@Bean("externalMongoTemplate")
fun externalMongoTemplate(): MongoTemplate = mongoTemplate()
}
@EnableMongoRepositories(
basePackages = ["com.example.multimongo.data.internal"],
mongoTemplateRef = "internalMongoTemplate")
@Configuration
class InternalDatabaseConfiguration : ExtraMongoConfiguration() {
@Value("\${additional-db.internal.uri:}")
override val uri: String? = null
@Value("\${additional-db.internal.host:}")
override val host: String? = null
@Value("\${additional-db.internal.port:0}")
override val port: Int? = 0
@Value("\${additional-db.internal.database:}")
override val database: String? = null
@Bean("internalMongoTemplate")
fun internalMongoTemplate(): MongoTemplate = mongoTemplate()
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment