Greetings to friends. I am encountering a problem when connecting to mongodb 3.0 using spring data, if I use a tag then it shows an authentication error message when my application queries the database and if I use and then my application gives a SAX exception in my mongoDb xml configuration file. And one more thing that I would like to mention here is we use the replica set in mongodb. Please suggest some solution for this problem. Thanks in advance.
<beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:mongo="http://www.springframework.org/schema/data/mongo" xsi:schemaLocation="http://www.springframework.org/schema/data/mongo http://www.springframework.org/schema/data/mongo/spring-mongo.xsd http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd"> <mongo:mongo-client id="mongo" replica-set="xxx.xx.x.xx:27017,xxx.xx.x.xx::27017" credentials="admin: abc_123@xyz "> <mongo:client-options write-concern="NONE" connections-per-host="10" connect-timeout="30000" max-wait-time="10000" /> </mongo:mongo-client> <bean id="mongoTemplate" class="org.springframework.data.mongodb.core.MongoTemplate"> <constructor-arg ref="mongo"/> <constructor-arg name="databaseName" value="xyz"/> </bean> </beans>
source share