spring.data.elasticsearch.cluster-nodes、cluster-name过时

(1) 这个在高版本中已经废弃,如果要继续使用请将spring-boot.version改为2.1.3.RELEASE时,这两个结点有效,没有过时。

(2) 这个在高版本中已经废弃,官方建议我们使用:High Level REST Client

@Configuration
public class ElasticsearchConfig {
    @Bean
    RestHighLevelClient elasticsearchClient() {
        ClientConfiguration configuration = ClientConfiguration.builder()
                .connectedTo("localhost:9300")
                //.withConnectTimeout(Duration.ofSeconds(5))
                //.withSocketTimeout(Duration.ofSeconds(3))
                //.useSsl()
                //.withDefaultHeaders(defaultHeaders)
                //.withBasicAuth(username, password)
                // ... other options
                .build();
        RestHighLevelClient client = RestClients.create(configuration).rest();
        return client;
    }
}
posted @ 2021-07-06 17:02  xudong5273  阅读(2793)  评论(0编辑  收藏  举报