Skip to content

Instantly share code, notes, and snippets.

@shazin
Last active December 9, 2017 05:13
Show Gist options
  • Save shazin/2d59f71beb0c413708c49d1440da0c36 to your computer and use it in GitHub Desktop.
Save shazin/2d59f71beb0c413708c49d1440da0c36 to your computer and use it in GitHub Desktop.
@SpringBootApplication(exclude = {MongoAutoConfiguration.class,
MongoDataAutoConfiguration.class })
@EnableReactiveMongoRepositories
@AutoConfigureAfter(EmbeddedMongoAutoConfiguration.class)
public class ApplicationConfiguration
extends AbstractReactiveMongoConfiguration {
private final Environment environment;
public ApplicationConfiguration(Environment environment) {
this.environment = environment;
}
@Bean
public LoggingEventListener mongoEventListener() {
return new LoggingEventListener();
}
@Override
@Bean
@DependsOn("embeddedMongoServer")
public MongoClient reactiveMongoClient() {
int port = environment.getProperty("local.mongo.port", Integer.class);
return MongoClients.create(String.format("mongodb://localhost:%d", port));
}
@Override
protected String getDatabaseName() {
return "reactive";
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment