Created
November 29, 2015 22:53
-
-
Save khamiltonuk/504cd8b0fdf237807ff1 to your computer and use it in GitHub Desktop.
Enabling MongoDB replica set
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
| @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