我正在使用Spring Boot 1.2.5和Spring-Boot-Starter-Data-Elasticsearch。我有一个自定义elasticsearch类,它代表一个节点并连接到远程ES实例。一切正常但是当我启动应用程序时,会启动两个ES节点而不是一个节点(在以下日志示例中为Overkill和Serpentina)。
我尝试使用Spring-Data-Elasticsearch或者只是从pom中删除ES,但它没有帮助。需要Starter-Data-Elasticsearch来实现依赖关系,一旦添加它,就会启动两个节点。
我还找到this question并尝试将spring.data.elasticsearch.local=false
添加到application.properties,但它没有改变任何内容。
我尝试将@EnableConfigurationProperties(ElasticsearchProperties.class)
添加到我的应用程序类中,但由于缺少依赖项,应用程序无法启动。
我找不到停用默认节点的可能性。我该如何禁用它?
启动日志:
[ main] org.elasticsearch.node : [Overkill] version[1.3.2], pid[2316], build[dee175d/2014-08-13T14:29:30Z]
[ main] org.elasticsearch.node : [Overkill] initializing ...
[ main] org.elasticsearch.plugins : [Overkill] loaded [], sites []
[ main] org.elasticsearch.node : [Overkill] initialized
[ main] org.elasticsearch.node : [Overkill] starting ...
[ main] org.elasticsearch.transport : [Overkill] bound_address {inet[/0:0:0:0:0:0:0:0:9300]}, publish_address {inet[/192.168.173.22:9300]}
[ main] org.elasticsearch.discovery : [Overkill] xyz/15kRC2sHR0SKamJerq0EXw
[ main] org.elasticsearch.discovery : [Overkill] waited for 30s and no initial state was set by the discovery
[ main] org.elasticsearch.http : [Overkill] bound_address {inet[/0:0:0:0:0:0:0:0:9200]}, publish_address {inet[/192.168.173.22:9200]}
[...]
[ main] org.elasticsearch.node : [Serpentina] version[1.3.2], pid[2316], build[dee175d/2014-08-13T14:29:30Z]
[ main] org.elasticsearch.node : [Serpentina] initializing ...
[ main] org.elasticsearch.plugins : [Serpentina] loaded [], sites []
[ main] org.elasticsearch.node : [Serpentina] initialized
[ main] org.elasticsearch.node : [Serpentina] starting ...
[ main] org.elasticsearch.transport : [Serpentina] bound_address {local[1]}, publish_address {local[1]}
[ main] org.elasticsearch.discovery : [Serpentina] elasticsearch/f5g45CHHSaCqrD8AFyNGWQ
[pdateTask][T#1]] org.elasticsearch.cluster.service : [Serpentina] new_master [Serpentina][f5g45CHHSaCqrD8AFyNGWQ][Blu][local[1]]{local=true}, reason: local-disco-initial_connect(master)
[ main] org.elasticsearch.node : [Serpentina] started
[pdateTask][T#1]] org.elasticsearch.gateway : [Serpentina] recovered [0] indices into cluster_state
我的ES课程:
@Repository
public class XyzRepository {
private Node node;
private Client client;
public XyzRepository (){
this.node = nodeBuilder().client(true).clusterName("clusterName").node();
this.client = node.client();
}
[... some functions...]
}
的pom.xml :
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>1.2.5.RELEASE</version>
<relativePath/> <!-- lookup parent from repository -->
</parent>
[...properties...]
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-elasticsearch</artifactId>
</dependency>
[...other dependencies...]