Download and Install
Install Dependencies
Ensure you have JDK version 8 or later installed in your development environment.
This guide shows you how to add the MongoDB Java driver dependencies using Maven or Gradle in an integrated development environment (IDE). We recommend that you use an IDE such as IntelliJ IDEA or Eclipse IDE. An IDE makes it more convenient to configure Maven or Gradle to build and run your project.
If you are not using an IDE, see Building Maven or Creating New Gradle Builds for more information about how to set up your project. See The MongoDB Reactive Streams Driver to download the driver and dependencies directly from Maven.
Install the Project Reactor Library
This guide uses methods from the Reactor library, a library based on the Reactive Streams specification.
Open a new Maven or Gradle project in your IDE. If you are using Maven, add the
following snippet to your pom.xml
:
<dependencyManagement> <dependencies> <dependency> <groupId>io.projectreactor</groupId> <artifactId>reactor-bom</artifactId> <version>2023.0.7</version> <type>pom</type> <scope>import</scope> </dependency> </dependencies> </dependencyManagement>
Then, add the following to your pom.xml
dependencies list:
<dependencies> <dependency> <groupId>io.projectreactor</groupId> <artifactId>reactor-core</artifactId> </dependency> <dependency> <groupId>io.projectreactor</groupId> <artifactId>reactor-test</artifactId> <scope>test</scope> </dependency> </dependencies>
To install Reactor using Gradle, see Getting Reactor in the Project Reactor documentation.
After you configure your dependencies, ensure they are available to your project by running your dependency manager and refreshing the project in your IDE.
Install the Java Reactive Streams driver
In your project, if you are using Maven, add the following to
your pom.xml
dependencies list:
<dependencies> <dependency> <groupId>org.mongodb</groupId> <artifactId>mongodb-driver-reactivestreams</artifactId> <version>5.2.1</version> </dependency> </dependencies>
If you are using Gradle, add the following to your
build.gradle
dependencies list:
dependencies { implementation 'org.mongodb:mongodb-driver-reactivestreams:5.2.1' }
After you configure your dependencies, ensure they are available to your project by running your dependency manager and refreshing the project in your IDE.
After you complete these steps, you have a new project and the driver dependencies installed.
Note
If you run into issues on this step, ask for help in the MongoDB Community Forums or submit feedback by using the Rate this page tab on the right or bottom right side of this page.