Monthly Archives: June 2020


Spring Boot Auto-configuration for Embedded MongoDB with Support for Transactions

By using EmbeddedMongoAutoConfiguration in Spring Boot, it is possible to test your code against a live MongoDB instance that is started and stopped automatically. In version 4.0, MongoDB supports multi-document transactions on replica sets. As of now (circa June 2020), Spring Boot doesn’t have out of the box support for testing with embedded MongoDB that supports such transactions. Below is the source code for a class – EmbeddedMongoWithTransactionsConfig – that allows you to do just that: start a single embedded MongoDB instance and configure it to support transactions on a replica set. To use it, just enable the embedMongoWithTxns profile […]