A sample Spring Boot 2.1.3 app which uses a custom configuration for reactive mongodb repository.
Exclude mongo configuration (the blocking one and part of reactive):
@SpringBootApplication(
exclude = {MongoAutoConfiguration.class, MongoReactiveDataAutoConfiguration.class})
Create your own implementation of AbstractReactiveMongoConfiguration
and annotate reactiveMongoClient()
with a @Bean
:
@Configuration
public class CustomerMongoConfig extends AbstractReactiveMongoConfiguration {
@Autowired private CustomerProperties properties;
@Override
@Bean
public MongoClient reactiveMongoClient() {
return MongoClients.create(properties.getMongoUri());
}
@Override
protected String getDatabaseName() {
return properties.getDatabase();
}
}