spring - NodeBuilder() 的替代方法是什么?它似乎已被弃用,我正在努力在 spring 数据中配置 Elasticsearch
问题描述
这就是我的代码目前的样子。这是我加载elasticsearch时需要的配置文件。
public class Elastic_config {
@Bean
NodeBuilder nodebuilder(){
return new NodeBuilder().Node();
}
@Bean
ElasticsearchTemplate elasticsearchOperations() throws IOException {
File tempFile = File.createTempFile("temp-elastic", Long.toString(System.nanoTime()));
Settings.Builder elasticsearchSettings =
Settings.settingsBuilder()
.put("http.enabled","true")
.put("index.number_of_shards", "1")
.put("path.data", new File(tempFile, "data").getAbsolutePath())
.put("path.logs", new File(tempFile, "logs").getAbsolutePath())
.put("path.work", new File(tempFile, "work").getAbsolutePath())
.put("path.home", tempFile);
return new ElasticsearchTemplate(nodeBuilder())
.local(true)
.settings(elasticsearchSettings.build())
.node()
.client();
}
}
解决方案
我使用了传输客户端来代替它。见链接 https://www.baeldung.com/spring-data-elasticsearch-tutorial
推荐阅读
- c++ - 重载 operator->() 以改变被调用函数的返回值
- javascript - 使用 React 检测窗口和视图负载
- c++ - 如何配置 Visual Studio Code C++ IntelliSense 以更好地自动完成
- jquery - 有什么方法可以为 jquery 中的元素定义我自己的“onSomeFunction”?
- python - 芹菜任务/工人分配逻辑
- rhel - 尝试在rhel box上通过pecl安装svn,但无法编译
- git - 无法在 BitBucket 上添加文件
- java - Spring JPA 没有为实体创建表
- laravel - 在路由中获取指定参数?
- android - Foursquare API 通过 Retrofit for Android 获取场地详细信息