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.
Add the Driver and Project Reactor Bill of Materials
In your IDE, create a new Maven or Gradle project. This guide uses methods from the Reactor library, a library based on the Reactive Streams specification, so you must add its Bill of Materials (BOM) for dependency management. Add the BOM for MongoDB JVM artifacts and Project Reactor to your project to organize dependency versions. The BOM simplifies dependency management by ensuring that you maintain consistent and compatible versions of dependencies, such as between the Java Reactive Streams driver and the core driver library. Use the BOM to avoid version conflicts and simplify upgrades.
Select from the following Maven and Gradle tabs to view instructions for adding the BOM for each dependency manager:
Add the following code to the dependencyManagement list in your
pom.xml file:
<dependencyManagement> <dependencies> <dependency> <groupId>org.mongodb</groupId> <artifactId>mongodb-driver-bom</artifactId> <version>5.4.0</version> <type>pom</type> <scope>import</scope> </dependency> <dependency> <groupId>io.projectreactor</groupId> <artifactId>reactor-bom</artifactId> <version>2025.0.0</version> <type>pom</type> <scope>import</scope> </dependency> </dependencies> </dependencyManagement>
Add the following code to the dependencies list in your
build.gradle.kts file. The code examples in this guide use the
Kotlin DSL for Gradle:
dependencies { implementation(platform("org.mongodb:mongodb-driver-bom:5.4.0")) implementation(platform("io.projectreactor:reactor-bom:2025.0.0")) }
To view a list of dependencies that the BOM manages, see the mongodb-driver-bom dependency and the reactor-bom dependency listings on the Maven Repository website.
Install the Project Reactor Library
If you are using Maven, add the
following to your pom.xml file:
<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 by using Gradle, add the following to your
build.gradle.kts dependencies list:
dependencies { ... implementation("io.projectreactor:reactor-core") }
Because you installed the BOM, you can omit a version in the Project Reactor dependency entry. The version you specify in the BOM determines the dependency versions to install.
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> </dependency> </dependencies>
If you are using Gradle, add the following to your
build.gradle.kts dependencies list:
dependencies { ... implementation("org.mongodb:mongodb-driver-reactivestreams") }
Because you installed the BOM, you can omit a version in the Java Reactive Streams driver dependency entry. The version you specify in the BOM determines the dependency versions to install.
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, submit feedback by using the Rate this page tab on the right or bottom right side of this page.
You can find support for general questions by using the MongoDB Stack Overflow tag or the MongoDB Reddit community.