Review
In 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 Contents
Part 1: IntroductionPart 2: Installation and configuration of Replica Sets
Part 3: Spring app configuration
Part 4: Testing the servers
Spring App Configuration
We 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!
Next
In 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
do you have replica with Credential ?
ReplyDeleteHi Mark,
ReplyDeleteI am getting the below issue when using the replica set as above
Cannot resolve reference to bean 'mongoReplicaSet' while setting constructor argument; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'mongoReplicaSet': Initialization of bean failed; nested exception is org.springframework.beans.ConversionNotSupportedException: Failed to convert property value of type [java.lang.String] to required type [com.mongodb.ServerAddress[]] for property 'replicaSetSeeds'; nested exception is java.lang.IllegalStateException: Cannot convert value of type [java.lang.String] to required type [com.mongodb.ServerAddress] for property 'replicaSetSeeds[0]': no matching editors or conversion strategy found
Could you please help me resolve this issue
Thanks,
Ram
I have read your blog its very attractive and impressive. I like it your blog.
ReplyDeleteSpring online training Spring online training Spring Hibernate online training Spring Hibernate online training Java online training
spring training in chennai spring hibernate training in chennai
yeezy wave runner 700
ReplyDeleteair jordan
curry 6
off white t shirt
travis scott jordan
palm angels
bape clothing
kyrie irving shoes
off white
off white hoodie