发生情况
导入依赖 <dependency> <groupId>org.elasticsearch.client</groupId> <artifactId>elasticsearch-rest-high-level-client</artifactId> <version>7.12.1</version> </dependency>
编写测试类 ``` @SpringBootTest class HotelAdminApplicationTests {
private RestHighLevelClient client;
@BeforeEach
void setUp(){
this.client = new RestHighLevelClient(RestClient.builder(
HttpHost.create("http://127.0.0.1:9200")
));
}
@AfterEach
void tearDown() throws IOException {
this.client.close();
}
@Test
void contextLoads() {
System.out.println(client);
}
} ```
解决方案
额外导入两个依赖 ``` org.elasticsearch.client elasticsearch-rest-client 7.12.1
org.elasticsearch elasticsearch 7.12.1 ```
导入后成功运行~