Created
August 20, 2019 22:31
-
-
Save timjonesdev/357dd1716eb135bcab78fa8c0039ca00 to your computer and use it in GitHub Desktop.
Extend the AbstractReactiveMongoConfiguration
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import com.mongodb.reactivestreams.client.MongoClient; | |
| import com.mongodb.reactivestreams.client.MongoClients; | |
| import org.springframework.context.annotation.Bean; | |
| import org.springframework.data.mongodb.config.AbstractReactiveMongoConfiguration; | |
| import org.springframework.data.mongodb.core.ReactiveMongoTemplate; | |
| import org.springframework.data.mongodb.repository.config.EnableReactiveMongoRepositories; | |
| /** | |
| * Config class to set up necessary components for watching the MongoDB change stream | |
| */ | |
| @EnableReactiveMongoRepositories | |
| public class ReactiveMongoConfig extends AbstractReactiveMongoConfiguration { | |
| @Bean | |
| public MongoClient reactiveMongoClient() { | |
| return MongoClients.create(); | |
| } | |
| @Bean | |
| public String getDatabaseName() { | |
| return "fantasy_db"; | |
| } | |
| @Bean | |
| public ReactiveMongoTemplate reactiveMongoTemplate() { | |
| return new ReactiveMongoTemplate(reactiveMongoClient(), getDatabaseName()); | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment