Dev Services
In dev (quarkus dev) and test mode the extension automatically starts a MongoDB Docker
container when quarkus.morphium.hosts is not explicitly configured. No additional setup is
needed.
How It Works
-
At build time, the extension checks whether
quarkus.morphium.hostsis set. -
If not set and Dev Services are enabled, a MongoDB container is started via Testcontainers.
-
The container’s mapped port and database name are injected as
quarkus.morphium.hostsandquarkus.morphium.database. -
The container is reused across live reloads — it is not restarted when you change code.
-
On JVM shutdown (Ctrl-C or test runner exit), the container is stopped automatically.
Configuration
| Property | Default | Description |
|---|---|---|
|
|
Set to |
|
|
Docker image to use (e.g. |
|
|
Database name injected into |
|
|
Start MongoDB as a single-node replica set. Enables multi-document transactions, change streams, and other oplog-dependent features. |
Replica-Set Mode
By default, Dev Services starts MongoDB as a single-node replica set via Testcontainers'
MongoDBContainer.withReplicaSet(). This enables multi-document transactions, change streams,
and @MorphiumTransactional out of the box.
The extension uses Testcontainers' MongoDBContainer which automatically:
-
Starts MongoDB with
--replSet -
Executes
rs.initiate() -
Waits for the node to become PRIMARY
This gives you a fully functional replica set in a single container.
Dev UI Card
In dev mode (quarkus dev), the extension registers a card in the Quarkus Dev UI at
/q/dev-ui/. The card queries the running Morphium instance at runtime via JsonRPC and
displays:
| Field | Description |
|---|---|
Hosts |
The |
Database |
The configured database name. |
Mode |
|
Driver |
The active Morphium driver implementation (e.g. |
Status |
|
Hot-Reload Behavior
When you save a file in dev mode:
-
The MongoDB container survives the live reload — it is not restarted.
-
The Morphium
ObjectMapperImplentity class cache is cleared so that ClassGraph re-scans the classpath with the newQuarkusClassLoader. Without this, stale class references from the previous class loader would cause entity mapping failures.
Disabling Dev Services
To use an external MongoDB instead of the automatic container:
quarkus.morphium.devservices.enabled=false
quarkus.morphium.hosts=my-mongo:27017
quarkus.morphium.database=mydb
Alternatively, simply setting quarkus.morphium.hosts is sufficient — Dev Services are
automatically skipped when hosts are explicitly configured.