Closed plzprayme closed 8 months ago
@plzprayme .. hmm.. i guess you have to exclude the configuration class as i had to do with spring 2.7.x .. where this annotation is on my autoconfig class:
@AutoConfigureBefore({ MongoAutoConfiguration.class, org.springframework.boot.autoconfigure.mongo.embedded.EmbeddedMongoAutoConfiguration.class })
... i have to think about this..
@michaelmosmann Thank you for your hint!
I reoslve it like this.
@SpringBootTest(
properties = [
"de.flapdoodle.mongodb.embedded.version=4.4.22",
]
)
@TestConstructor(autowireMode = TestConstructor.AutowireMode.ALL)
class EmbeddedMongoTestContext {
@Test
fun testSomething() { /** TODO **/ }
}
class EmbeddedMongoTest(
private val simpleRepository: SimpleRepository
) : EmbeddedMongoTestContext() {
@Test
fun example() {
// get data from embed mongo db
println(simpleRepository.findAll())
}
}
@EnableAutoConfiguration( exclude = [EmbeddedMongoAutoConfiguration::class] ) << just add this line
@SpringBootTest(
properties = [
"spring.data.mongodb.uri=mongodb://....",
]
)
@TestConstructor(autowireMode = TestConstructor.AutowireMode.ALL)
class RealMongoTestContext {
@Test
fun testSomething() { /** TODO **/ }
}
class RealMongoTest(
private val simpleRepository: SimpleRepository
) : RealMongoTestContext() {
@Test
fun example() {
// get data from real mongo db
println(simpleRepository.findAll())
}
}
How about add this use case on spring-3.0.x ?
@plzprayme thanks.. i will see if i can add this to the documentation .. :)
@plzprayme Done:)
Hello, michael! Thank you for share this awesome project to the world.
I just want a use embed mongo with spring autoconfigured mongo. can you give me a hint?
my hope example:
There is no way to disable autoconfiguration options? I just want a create embed mongo, spring autoconfigured mongo by myself.
Thank you.