0
默認情況下,Spring Boot將創建嵌入式Elasticsearch。可以通過設置spring.data.elasticsearch.cluster-nodes來關閉它。但是,我不確定如何在JUnit測試中執行此操作。例如,我有:在Spring Boot測試中關閉嵌入式Elasticsearch
@Slf4j
@RunWith(SpringJUnit4ClassRunner.class)
@SpringApplicationConfiguration(RemoteElasticsearch.class)
@SpringBootApplication(
scanBasePackageClasses = {
}
)
@EnableElasticsearchRepositories(basePackages = "com.example.me.repo")
public class RemoteElasticsearch {
@Inject
private SomeRepo someRepo;
@Test
public void test(){
someRepo.save(new Something());
}
}
它連接到遠程elasticsearch如果我設置相應的環境變量(例如spring.data.elasticsearch.cluster節點=宿主:9300)。我能以某種方式直接在這個測試中設置這個值嗎?