ReviewIn the previous section, we have installed and configured our servers for MongoDB replication. In this section, we will update our Spring application to support MongoDB Replica Sets.
Table of ContentsPart 1: Introduction
Part 2: Installation and configuration of Replica Sets
Part 3: Spring app configuration
Part 4: Testing the servers
Spring App ConfigurationWe have setup a MongoDB Replica Set using four servers, and we've examined the output from the logs and verified that all instances are running. Our next step is to configure our Spring MongoDB-base application.
Since we're reusing our application from the tutorial Spring MVC 3.1 - Implement CRUD with Spring Data MongoDB, adding a MongoDB Replica Set support in Spring is trivial. All we need to do is modify the spring.properties file with the following contents (this file is located under the WEB-INF directory):
Then we have to modify as well the spring-data.xml file with the following updates:
That's all we need to for our Spring application!
NextIn the next section, we will run and test our servers to verify and test our MongoDB cluster for replication. Click here to proceed.
Share the joy:
Subscribe by reader Subscribe by email Share