Skip to content

Instantly share code, notes, and snippets.

@khamiltonuk
Created November 29, 2015 22:53
Show Gist options
  • Select an option

  • Save khamiltonuk/504cd8b0fdf237807ff1 to your computer and use it in GitHub Desktop.

Select an option

Save khamiltonuk/504cd8b0fdf237807ff1 to your computer and use it in GitHub Desktop.
Enabling MongoDB replica set
@Configuration
@EnableMongoRepositories({"com.foo.repository"})
public class MongoRepositoryConfig{
@Value("localhost:27017, localhost:27018")
private ServerAddress[] serverAddressList;
@Bean
@Override
public Mongo mongo() throws Exception {
return new Mongo(Arrays.asList(serverAddressList));
}
@Bean
public static CustomEditorConfigurer customEditorConfigurer(){
CustomEditorConfigurer configurer = new CustomEditorConfigurer();
configurer.setPropertyEditorRegistrars(
new PropertyEditorRegistrar[]{new ServerAddressPropertyEditorRegistrar()});
return configurer;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment