Closed enolive closed 1 year ago
@enolive thats one way to go ..
you can set the base dir also with an env variable as you can see here: https://github.com/flapdoodle-oss/de.flapdoodle.embed.mongo/blob/main/src/main/java/de/flapdoodle/embed/mongo/transitions/ExtractFileSet.java#L60
You can also use:
Start.to(PersistenDir::class.java) .providedBy(PersistentDir.inWorkingDir(".embeddedMongodbCustomPath") .mapToUncheckedException(RuntimeException::new))
.. this way it will be evaluated later.. and you must handle a possible IOException .. in this case it will be mapped to a RuntimeException ..
There are at least two options .. a) use the builder pattern, b) use method overrides.. but i had some strange case, where this did not work in one case.. so builder pattern should work..
@enolive spring 3.x changed some internals .. i have to find a way to restore this port handling from 2.7.x somehow...
thanks for your helpful pointers!
While the ENV variable solution would be a very elegant solution to my nasty CI/CD problem, it would force me to scatter the embedded mongo configuration to different locations which I'd like to avoid.
I like the .mapToUncheckedException(...)
operation, but it seems to depend on a later version of de.flapdoodle.embed.mongo:4.3.*
than the one specified as the peer dependency of *.spring30x:4.3.2
(same goes for the 4.3.3-SNAPSHOT version I find here in the repo). I want to avoid messing around with overriden peer dependencies if possible.
An updated version of spring30x with new peer dependencies would be really helpful to me :wink:
@enolive there will be a new version soon ..
I am similarly looking for a way to configure the storage directory of the embedded database. With Spring's old implementation this used to be accomplished by setting spring.mongodb.embedded.storage.databaseDir
.
I tried de.flapdoodle.mongodb.embedded.storage.databaseDir
but it appears that had no affect.
@mcordeiro73 ah.. ok. I think i can reimplement this feature ..
@mcordeiro73 feature is back as you can see here: https://github.com/flapdoodle-oss/de.flapdoodle.embed.mongo.spring/blob/main/HowTo.md#custom-database-dir .. you must use de.flapdoodle.mongodb.embedded.databaseDir (backport to my spring3.0.x, spring2.7.x and spring2.6.x adapter) ..
can you close this, if this works for you? .. and if not, please open an new issue:)
@michaelmosmann The property worked great. Not sure I can close the issue since I didn't open it. @enolive would you like to do the honors?
@mcordeiro73 @enolive .. so i will close this:)
I am struggling to find a proper way to customize the embedded mongo.
I am looking for a way to override
$HOME/.embedmongo
which won't work correctly on our CI/CD system (for reasons :wink:)I am aware of the Customizations described in the Howto Document but I am not sure if I adapted it correctly to a Spring Boot Application. I am also aware that I can easily set the mongo version with the property
de.flapdoodle.mongodb.embedded.version
Problems that I see:
net
property, Spring Boot tries to connect to the default mongo port (27017) which will fail. I got this hack by looking at the internals ofEmbeddedMongoAutoConfiguration
PersistentDir.inWorkingDir
returns aThrowingSupplier
I have no clue how to use properly in a Transition. Usingget()
seems like a dirty hack on an "Either-like" data typeas you might see, I am using Kotlin. I can also provide a Java sample instead if needed!