Skip to content

Instantly share code, notes, and snippets.

@avk2 avk2/.java
Last active May 31, 2017

Embed
What would you like to do?
@Configuration
@EnableMongoRepositories(basePackages = "com.foo.repo")
class MongoConfig extends AbstractMongoConfiguration {
@Value("${spring.data.mongodb.host}")
private String url;
@Value("${spring.data.mongodb.port}")
private int port;
@Value("${spring.data.mongodb.database}")
private String db;
@Override
protected String getDatabaseName() {
return db;
}
@Override
public Mongo mongo() throws Exception {
return new MongoClient(url, port);
}
@Override
protected Collection<String> getMappingBasePackages() {
return Arrays.asList("com.foo");
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.