From 4ce345225e6e77326cef70260b272a19ca030dbe Mon Sep 17 00:00:00 2001 From: Mubarak Date: Sat, 7 Dec 2024 11:05:21 +0000 Subject: [PATCH] easy configuraation for MongoDB Atlas --- .../ROOT/pages/mongodb/configuration.adoc | 46 +++++++++++++++++++ 1 file changed, 46 insertions(+) diff --git a/src/main/antora/modules/ROOT/pages/mongodb/configuration.adoc b/src/main/antora/modules/ROOT/pages/mongodb/configuration.adoc index 1034acdd79..6361cb2c16 100644 --- a/src/main/antora/modules/ROOT/pages/mongodb/configuration.adoc +++ b/src/main/antora/modules/ROOT/pages/mongodb/configuration.adoc @@ -334,3 +334,49 @@ XML:: ---- ====== += Connecting to MongoDB Atlas Using the Connection String + +If you are using a MongoDB Atlas online instance, you can simplify the configuration process by utilizing the connection string provided in the MongoDB Atlas UI. Follow these steps: + +== Retrieve the Connection String +Retrieve the connection string for your cluster from the MongoDB Atlas UI. This string includes the required credentials and cluster details. + +== Configure Your Application +Add the connection string to your `application.properties` or `application.yml` file as follows: + +=== For `application.properties` +```properties +spring.data.mongodb.uri= +spring.data.mongodb.database= + +=== For application.yml + +```yaml +spring: + data: + mongodb: + uri: + database: + +NOTE: if the specified database does not exist, MongoDB will create one automatically once the application starts. +Also, you will need these required dependencies in your `pom.xml`(Maven) or `build.gradle`(Gradle) files. +=== Maven +xml + + org.springframework.boot + spring-boot-starter-data-mongodb + + + +org.mongodb +mongodb-driver-sync +5.2.1 + +Be sure to replace the version numbers with the latest versions. +=== Gradle + +groovy +implementation 'org.springframework.boot:spring-boot-starter-data-mongodb' +implementation 'org.mongodb:mongodb-driver' + +That's it , you are good to go , spring will take care of the rest. \ No newline at end of file