Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
46 changes: 46 additions & 0 deletions src/main/antora/modules/ROOT/pages/mongodb/configuration.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -334,3 +334,49 @@ XML::
</bean>
----
======
= 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=<your-connection-string>
spring.data.mongodb.database=<your-database-name>

=== For application.yml

```yaml
spring:
data:
mongodb:
uri: <your-connection-string>
database: <your-database-name>

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
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-mongodb</artifactId>
</dependency>

<dependency>
<groupId>org.mongodb</groupId>
<artifactId>mongodb-driver-sync</artifactId>
<version>5.2.1</version>
</dependency>
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.
Loading