Morphia createDatastore won't accept com.mongodb.client.MongoClient object with new mongo driver version

160 views Asked by At

Since upgrading from mongo-java-driver to mongodb-driver-sync(4.6.1), I am unable to use createDatastore method because it's looking for a com.mongodb.MongoClient object (which is discontinued) instead of
com.mongodb.client.MongoClient object:

client = MongoClients.create(settings);
datastore = morphia.createDatastore(client, databaseName);

Does anyone know a workaround for this? I've tried casting but that doesn't seem to work.

1

There are 1 answers

1
Enowneb On

The changing of com.mongodb.MongoClient to com.mongodb.client.MongoClient for Morphia library was released in 2.0.0:

https://github.com/MorphiaOrg/morphia/issues/1319

So you should also update your Morphia library to a newer version, for example:

implementation group: 'dev.morphia.morphia', name: 'morphia-core', version: '2.3.0'