Springboot 2 @DataMongoTest错误

我试图在使用kotlin的springboot应用程序中运行一些测试。 挑战是@DataMongoTest中的嵌入式mongodb在随机端口上打开,而弹簧引导数据mongo正在默认端口上寻找连接

我的配置如下:

@Configuration @ComponentScan(basePackages = ["zw.co.ift.creditrating.persistence"]) @EnableReactiveMongoRepositories(basePackages = [("zw.co.ift.creditrating.persistence.repository")]) class PersistenceConfiguration : AbstractReactiveMongoConfiguration() { @Bean override fun reactiveMongoClient() = MongoClients.create() override fun getDatabaseName() = "bank" } 

我的测试如下:

 @DataMongoTest @ContextConfiguration(classes = [(PersistenceIntegrationConfiguration::class)]) @EnableAutoConfiguration @ExtendWith(SpringExtension::class) 

现在以下是我正在运行的测试的输出:

2017-12-07 20:15:56.910 INFO 52176 — [Thread-7] osbamongo.embedded.EmbeddedMongo:2017-12-07T20:15:56.909 + 0200 I CONTROL [initandlisten] MongoDB starting:pid = 52177 port = 61313 dbpath = / var / folders / s7 / k998tmv12tvg_q_vkp29_xhr0000gn / T / embedmongo-db-cd77207c-2978-466a-b380-3f51008e4fa6 64位主机= Oswins-MacBook-Pro.local

和错误:

2017-12-07 20:15:57.552 INFO 52176 — [main] org.mongodb.driver.cluster:使用设置{hosts = [localhost:27017],mode = SINGLE,requiredClusterType = UNKNOWN,serverSelectionTimeout =’ 30000 ms’,maxWaitQueueSize = 500} 2017-12-07 20:15:57.780信息52176 — [localhost:27017] org.mongodb.driver.cluster:监视器线程连接到服务器localhost时出现exception:27017

有无论如何修复嵌入式mongo数据库端口或让客户端查找端口?