Spring Data Elasticsearch:path.home未配置错误

时间:2016-11-07 08:20:15

标签: spring elasticsearch spring-data

我尝试使用Spring Data Elasticsearch创建一个示例项目,但由于path.home is not configured错误而无法继续。我的弹性搜索版本 2.3.3 。我已经使用注释来创建bean,如下所示:

@Bean
public static NodeBuilder nodeBuilder() {
    return new NodeBuilder();
}

@Bean
public ElasticsearchTemplate elasticsearchTemplate() {
    return new ElasticsearchTemplate(getNodeClient());
}

@Bean
private static NodeClient getNodeClient() {
    return (NodeClient) nodeBuilder().clusterName(UUID.randomUUID().toString()).local(true).node().client();
}

我的spring-data-elasticsearch版本:

enter image description here

我错过了什么吗?

1 个答案:

答案 0 :(得分:0)

提供路径作为NodeBuilder的设置:

@Bean
public Settings elasticsearchSettings() {

     Settings.Builder elasticsearchSettings = Settings.settingsBuilder()
         .put("path.home", "/foo/bar");

        return elasticsearchSettings.build();
}

@Bean
public ElasticsearchTemplate elasticsearchTemplate() {

    return new ElasticsearchTemplate(NodeBuilder.nodeBuilder()
        .settings(elasticsearchSettings()).node().client());
}

如果使用Spring Boot,this描述了.properties文件的用法:

spring.data.elasticsearch.properties.path.home=/foo/bar