Embedded MongoDB for unit testing and developement purposes. Based on flapdoodle-oss/de.flapdoodle.embed.mongo
7.x requires Java 17.
8.x requires Java 21.
- Add the embedded-mongodb dependency to your pom.xml:
<dependency>
<groupId>de.svenkubiak</groupId>
<artifactId>embedded-mongodb</artifactId>
<version>x.x.x</version>
</dependency>
- Start the embedded MongoDB by calling the following method
EmeddedMongoDB.create().start();
This will start an in-memory MongoDB with default options at localhost on port 29019 with the latest "production" version of Mongo DB.
EmbeddedMongoDB embeddedMongoDB = EmbeddedMongoDB.create()
.withHost("localhost")
.withPort(27017)
.withVersion(Main.V3_6)
.start();
if (embeddedMongoDB.isActive()) {
//do something
}