This repository is deprecated and no longer actively maintained. It contains outdated code examples or practices that do not align with current MongoDB best practices. While the repository remains accessible for reference purposes, we strongly discourage its use in production environments. Users should be aware that this repository will not receive any further updates, bug fixes, or security patches. This code may expose you to security vulnerabilities, compatibility issues with current MongoDB versions, and potential performance problems. Any implementation based on this repository is at the user's own risk. For up-to-date resources, please refer to the MongoDB Developer Center.
This is a demo springboot application created using IntelliJ Spring Initialzr And Azure Plugin to show how to connect to Atlas using a Java Spring Boot Application and deploy it as a Microsoft Azure Wep App(AppService)
- Java 11 (Microsoft OpenJDK )
- Spring boot 2.7.10
- Spring Data MongoDB
- MongoDB Atlas
- Maven
- Get started with a Free Tier Cluster on MongoDB Atlas.
- Read this blog post: Quick Start - Getting your Free MongoDB Atlas Cluster.
- You might need to add mongodb.properties file if you don't want to use application properties directly, (the benefit lies that the optional properties file could be added to gitignore and used only for dev purposes and secrets never flow to Git) and add the default MongoDB URI
spring.data.mongodb.uri, databasespring.data.mongodb.database(if required).
Please note:
- Spring data automatically detects the database either from the connection string (spring.data.mongodb.uri)
- if spring.data.mongodb.database is specified, this value is taken as the database and it overrides the database specified in the above key (URL), and
- the collection is taken by spring.data.mongodb.collection or @Document annotation, if this property is not specified
Replace the Atlas URI in application.properties and run as a spring boot application.
- Start the server in a console with
mvn spring-boot:run. - If you add some Unit Tests, you would start them with
mvn clean test. - You can build the project with
mvn clean package.
Use at your own risk; not a supported MongoDB product
- Megha Arora @ MongoDB.