spring.data.elasticsearch.cluster-nodes、cluster-name过时
这个在高版本中已经废弃,官方建议我们使用:High Level REST Client@Configurationpublic class ElasticsearchConfig {/*** localhost:9300 写在配置文件中就可以了*/@BeanRestHighLevelClient elasticsearchClient() {ClientConfiguration configur
·
这个在高版本中已经废弃,官方建议我们使用:High Level REST Client
@Configuration
public class ElasticsearchConfig {
/**
* localhost:9300 写在配置文件中就可以了
*/
@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;
}
}
但我在spring-boot.version
改为2.1.3.RELEASE
时,这两个结点有效,没有过时。

魔乐社区(Modelers.cn) 是一个中立、公益的人工智能社区,提供人工智能工具、模型、数据的托管、展示与应用协同服务,为人工智能开发及爱好者搭建开放的学习交流平台。社区通过理事会方式运作,由全产业链共同建设、共同运营、共同享有,推动国产AI生态繁荣发展。
更多推荐
所有评论(0)