【发布时间】:2020-08-06 19:37:27
【问题描述】:
我正在使用带有这些注释的基本集成测试:
@ExtendWith(SpringExtension::class)
@SpringBootTest(classes = [SomeApplication::class], webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT)
@DataMongoTest
@EmbeddedKafka(
partitions = 3,
controlledShutdown = false,
brokerProperties = ["listeners=PLAINTEXT://127.0.0.1:9092", "port=9092"])
abstract class IntegrationTestBase {
当我运行测试时,我得到了这个错误:
java.lang.IllegalStateException: Configuration error: found multiple declarations of @BootstrapWith for test class [com.some.app.application.restapi.DatabaseSetupApiEte]: [@org.springframework.test.context.BootstrapWith(value=org.springframework.boot.test.context.SpringBootTestContextBootstrapper), @org.springframework.test.context.BootstrapWith(value=org.springframework.boot.test.autoconfigure.data.mongo.DataMongoTestContextBootstrapper)]
错误是由@SpringBootTest和@DataMongoTest这两个注解引起的,包括@BootstrapWith
像这样:
@SpringBootTest has @BootstrapWith(SpringBootTestContextBootstrapper.class)
@DataMongoTest has @BootstrapWith(DataMongoTestContextBootstrapper.class)
我需要继续将@SpringBootTest 用于SpringBootTest.WebEnvironment.RANDOM_PORT,但我也想要来自@DataMongoTest 的嵌入式mongodb
有什么建议吗?
【问题讨论】:
-
enter link description herethis 和这个的可能重复
标签: java spring-boot kotlin