1

I'm trying to use Azure Cosmos DB instead of MongoDB with my Spring boot app.

Currently, I'm using the mongo.host/database/port properties. I couldn't find where I can set the SSL option and replicaSet or alternatively the full client URI.

This is the code they suggesting and it's working, but it's not helping me...

MongoClient mongoClient = new MongoClient(
    new MongoClientURI("mongodb://[user]:[pass]@[host]:[port]/?ssl=true&replicaSet=globaldb"));
Ori Marko
  • 56,308
  • 23
  • 131
  • 233
Jonathan
  • 35
  • 1
  • 6
  • 2
    *"I'm trying to use Azure Cosmos DB instead of MongoDB"* -- this is not a wise idea. Despite all claims of "compatibilty", an apple is simply not an orange. If you want to use XYZ Database engine then I strongly suggest you actually use the native API of XYZ database engine. Some things will work, and others will not. Most reports lean heavily on the "not" and it does not escape notice that once available published "compatibility matrix" details are now very difficult if not impossible to find. Compatibility layers are not a new thing. And historically they never live up to claims. – Neil Lunn Sep 13 '17 at 07:04

1 Answers1

0

Can you try just using the "spring.data.mongodb.uri" property instead of specifying the host/database/port separately?

The official documentation (https://docs.spring.io/spring-boot/docs/current-SNAPSHOT/reference/htmlsingle/#boot-features-connecting-to-mongodb) also recommends this approach while connecting to replica-sets.

This issue is also discussed at How to configure spring-data-mongodb to use a replica set via properties

Siddhesh Vethe
  • 226
  • 1
  • 3
  • Thanks, I've tried the URI and now it's working. The problem was that I override AbstractMongoConfiguration bean with my test sources by mistake, that is why the parameters were not working. – Jonathan Sep 14 '17 at 20:30