Skip to content

Connect Spring MVC with aws documentDB

I’m using mongoDB with aws ec2 instance it’s working fine and I’ve moved mongoDB to aws documentDB, So i’m not able to connect documentDB with same code, So any one can u please help me if you have idea.

Here is my connection code in Spring MVC:

public MongoDbFactory mongoDbFactory() throws UnknownHostException {
   return new SimpleMongoDbFactory(new MongoClient(env.getProperty(""), Integer.parseInt(env.getProperty("mongo.database.port"))), env.getProperty(""));

Spring, Hibernet and mongoDB version: spring -4.2.5
spring-data-MongoDB -1.10.14
mongo-java-driver -3.5.0



To connect using TLS, you will have to import the rds-combined-ca-bundle file. I would suggest go through: and check the sample logic given for java.

7 People found this is helpful