Maven plugin wrapper for the embedded MongoDB API
Latest commit bfeef6a Jan 22, 2016 @joelittlejohn Update docs for 0.3.4

embedmongo-maven-plugin Build Status Maven Central

Maven plugin wrapper for the embedded MongoDB API.

This plugin lets you start and stop an instance of MongoDB during a Maven build, e.g. for integration testing. The Mongo instance isn't strictly embedded (it's not running within the JVM of your application), but it is a managed instance that exists only for the lifetime of your build.


        <!-- optional, default 27017 -->

        <!-- optional, default is false, if true allocates a random port and overrides embedmongo.port -->

        <!-- optional, default 2.2.1 -->

        <!-- optional, default is a new dir in -->

        <!-- optional (file|console|none), default console -->

        <!-- optional, can be used when logging=file, default is ./embedmongo.log -->

        <!-- optional, can be used when logging=file, default is utf-8 -->

        <!-- optional, default is to listen on all interfaces -->

        <!-- optional, default is -->

        <!--optional, one of wiredTiger or mmapv1 (default is mmapv1) -->

        <!-- optional, skips this plugin entirely, use on the command line like -Dembedmongo.skip -->

        <!-- optional, default 2.2.1 -->

        <!-- a directory containing scripts to run -->

        <!-- optional, valid charset encoding for loading the scripts. Uses the underlying charset encoding of the platform if not assigned -->

        <!-- the name of the database to run scripts against -->

        <!-- optional, default 2.2.1 -->

        <!-- optional, name of the default database to import data -->

        <!-- optional, default false, if true it launches in parallel all imports -->

        <!-- optional, default false, if true it will wait forever after it imports the data -->

            <!-- optional, name of the database, if null it will fallback to defaultImportDatabase -->

            <!-- optional, collection to import data into (will use <file> to derive this otherwise) -->

            <!-- required, name of the json file to import -->

            <!-- optional, default true, if true it will do an upsert on each document imported -->

            <!-- optional, default true, if true it will do a drop the collection before starts to import -->

            <!-- optional, default 20000, it will fail if it takes more than this time importing a file (time in millis) -->

          <!-- More imports are accepted and it will be executed in strictly order (if parallel is not set) -->


  • By default, the start goal is bound to pre-integration-test, the stop goal is bound to post-integration-test. You can of course bind to different phases if required.
  • If you omit/forget the stop goal, any Mongo process spawned by the start goal will be stopped when the JVM terminates.
  • If you want to run Maven builds in parallel you can use randomPort to avoid port conflicts, the value allocated will be available to other plugins in the project as a property embedmongo.port. If you're using Jenkins, you can also try the Port Allocator Plugin.
  • If you need to use a proxy to download MongoDB then you can either use -Dhttp.proxyHost and -Dhttp.proxyPort as additional Maven arguments (this will affect the entire build) or add proxy settings to your settings.xml.
  • If you're having trouble with Windows firewall rules, try setting the bindIp config property to
  • If you'd like the start goal to start mongodb and wait, you can add -Dembedmongo.wait to your Maven command line arguments or -Dembedmongo.import.wait if you want the imports
  • If you are using a charset encoding to load scripts, refer to the IANA Charset Registry. Accepted charsets are found in the Preferred MIME Name column.