JNOSQL / jnosql.github.io

The JNoSQL is a framework whose has the goal to help Java developers to create Java EE applications with NoSQL, whereby they can make scalable application beyond enjoy the polyglot persistence.
http://jnosql.org/
MIT License
19 stars 10 forks source link

Help : How to provide MongoCredentials to createMongoDbDocumentConfiguration #33

Closed genxlogics closed 1 year ago

genxlogics commented 3 years ago

I see the example only shows the mongodb-host property. I wanted to know how to include the mongo credentials to create Configuration object.

dearrudam commented 1 year ago

@genxlogics, you can define the database settings using the MicroProfile Config specification, so you can add properties and overwrite it in the environment following the Twelve-Factor App.

For your scenario, you can define the Mongo credentials in the microprofile-config.properties:

jnosql.mongodb.user=??? # The user’s userID.
jnosql.mongodb.password=??? # The user’s password
jnosql.mongodb.authentication.source=??? # The source where the user is defined.
jnosql.mongodb.authentication.mechanism=??? # Authentication mechanisms com.mongodb.AuthenticationMechanism

Or by defining the environment variables like:

JNOSQL_MONGODB_USER=???
JNOSQL_MONGODB_PASSWORD=???
JNOSQL_MONGODB_AUTHENTICATION_SOURCE=???
JNOSQL_MONGODB_AUTHENTICATION_MECHANISM=???

For more info: https://github.com/eclipse/jnosql-databases#configuration-10