An embedded database runs within the application process or development environment instead of requiring a separately managed database service. It gives development and testing projects a ready-to-use database without installing or starting a separate server. section 4.2.1 section 3.1.2
Embedded databases are useful when you need:
- A local MongoDB substitute supplied through the Flapdoodle embedded MongoDB dependency. section 4.2.1
- An in-memory H2 database for Spring JDBC development, with an optional fixed database name for console access. section 3.1.2
- Clean test or development state, because embedded MongoDB data is wiped when the application restarts. section 4.2.1
Switching from local MongoDB to embedded MongoDB
Spring Data MongoDB normally expects a MongoDB server on localhost:27017. Adding the Flapdoodle dependency removes that separate-server requirement for development and testing. For production, configure the external MongoDB host, port, credentials, and database name instead. section 4.2.1
<dependency> <groupId>de.flapdoodle.embed</groupId> <artifactId>de.flapdoodle.embed.mongo</artifactId> <!-- <scope>test</scope> --> </dependency>
Use the Flapdoodle dependency to add an embedded MongoDB implementation to a Spring Boot build. section 4.2.1
spring:
data:
mongodb:
host: mongodb.tacocloud.com
port: 27017
username: tacocloud
password: s3cr3tp455w0rd
database: tacoclouddb
Use these Spring Data MongoDB properties when production data lives in an externally managed MongoDB server. section 4.2.1

