1.依賴
我用的是 springboot 2.5.4【所以spring-boot-starter-data-elasticsearch 的版本也是 2.5.4】此時對應的 elasticsearch 服務端和客戶端的版本是 7.12.1 那要部署的ES版本也要是 7.12.1:
<!-- https://mvnrepository.com/artifact/org.springframework.boot/spring-boot-starter-data-elasticsearch -->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-elasticsearch</artifactId>
</dependency>
2.配置資訊
spring:
elasticsearch:
rest:
uris: localhost:9200
3.客戶端使用
@SpringBootTest
class EsStarterApplicationTests {
@Autowired
private RestHighLevelClient restHighLevelClient;
@Test
void contextLoads() {
}
}
由于不同版本的API不同【沒有參考價值】,這里不再貼出測驗代碼,
轉載請註明出處,本文鏈接:https://www.uj5u.com/qita/301238.html
標籤:其他
