For the most recent version of the reference documentation, see our MongoDB Java Driver documentation site.
- MongoDB Driver
- Installation
Installation
The recommended way to get started using one of the drivers in your project is with a dependency management system.
There are two Maven artifacts available in the release. The preferred artifact for new applications is mongodb-driver
however, we still publish the legacy mongo-java-driver
uber-jar.
MongoDB Driver
The MongoDB Driver mongodb-driver
is the updated synchronous Java driver that includes the legacy API as well as a new generic MongoCollection
interface that complies with a new cross-driver CRUD specification.
important
mongodb-driver
is not an OSGi bundle: both mongodb-driver
and mongodb-driver-core
, a dependency of mongodb-driver
, include classes from the com.mongodb
package.
For OSGi-based applications, use the mongo-java-driver uber jar instead.
<dependencies>
<dependency>
<groupId>org.mongodb</groupId>
<artifactId>mongodb-driver</artifactId>
<version>3.6.4</version>
</dependency>
</dependencies>
Note: You can also download the mongodb-driver
jar
directly
from sonatype.
If downloading mongodb-driver
manually,
you must also download its dependencies:
bson
and
mongodb-driver-core
Uber Jar (Legacy)
For new applications, the preferred artifact is mongodb-driver; however, the legacy mongo-java-driver
uber jar is still available. The uber jar contains: the BSON library, the core library, and the mongodb-driver
.
Note
The mongo-java-driver
artifact is a valid OSGi bundle.
<dependencies>
<dependency>
<groupId>org.mongodb</groupId>
<artifactId>mongo-java-driver</artifactId>
<version>3.6.4</version>
</dependency>
</dependencies>
Note: You can also download the mongo-java-driver
jar
directly
from sonatype.