title: How to configure two instance mongodb use spring boot and spring data
body: <p>The First instance is the embedded MongoDb, the second instance is the live MongoDb.
  How do it configure use spring data and spring boot. How to switch easily these instances by properties file??</p>
  
  <p><strong>UPDATE</strong></p>
  
  <ul>
  <li><p>By default application should start build-in database and store data
  into APPDIR/db directory</p></li>
  <li><p>It should be possible to let application know that external database
  will be used by configuring mongo.url property. In this case no need
  to start internal database. Instead of that external connection
  should be used</p></li>
  </ul>
  
  <p>Paste some configuration, please.</p>
  
  <p><strong>UPDATE</strong>
  I have:</p>
  
  <pre><code>&lt;!--Embedded MongoDB--&gt;
  &lt;dependency&gt;
      &lt;groupId&gt;de.flapdoodle.embed&lt;/groupId&gt;
      &lt;artifactId&gt;de.flapdoodle.embed.mongo&lt;/artifactId&gt;
      &lt;version&gt;1.50.5&lt;/version&gt;
  &lt;/dependency&gt;
  
  spring.data.mongodb.host=localhost
  spring.data.mongodb.port=27017
  spring.data.mongodb.uri=mongodb://localhost/test
  spring.data.mongodb.database=test
  
  # EMBEDDED MONGODB (EmbeddedMongoProperties)
  #spring.mongodb.embedded.storage.databaseDir=c:/db
  #spring.mongodb.embedded.version=3.2.2
  </code></pre>
  
  <p>if I'll specify external mongodb, then i want  embedded mongodb shouldn't to startup.</p>
  
  <pre><code>java.io.IOException: Could not start process: &lt;EOF&gt;
      at de.flapdoodle.embed.mongo.AbstractMongoProcess.onAfterProcessStart(AbstractMongoProcess.java:79) ~[de.flapdoodle.embed.mongo-1.50.5.jar!/:?]
      at de.flapdoodle.embed.process.runtime.AbstractProcess.&lt;init&gt;(AbstractProcess.java:114) [de.flapdoodle.embed.process-1.50.2.jar!/:?]
      at de.flapdoodle.embed.mongo.AbstractMongoProcess.&lt;init&gt;(AbstractMongoProcess.java:53) [de.flapdoodle.embed.mongo-1.50.5.jar!/:?]
      at de.flapdoodle.embed.mongo.MongodProcess.&lt;init&gt;(MongodProcess.java:50) [de.flapdoodle.embed.mongo-1.50.5.jar!/:?]
      at de.flapdoodle.embed.mongo.MongodExecutable.start(MongodExecutable.java:44) [de.flapdoodle.embed.mongo-1.50.5.jar!/:?]
      at de.flapdoodle.embed.mongo.MongodExecutable.start(MongodExecutable.java:34) [de.flapdoodle.embed.mongo-1.50.5.jar!/:?]
      at de.flapdoodle.embed.process.runtime.Executable.start(Executable.java:101) [de.flapdoodle.embed.process-1.50.2.jar!/:?]
      at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[?:1.8.0_05]
      at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[?:1.8.0_05]
      at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[?:1.8.0_05]
      at java.lang.reflect.Method.invoke(Method.java:483) ~[?:1.8.0_05]
  </code></pre>