关于elasticsearch:Elasticsearch整合SpringBoot-配置文件

7次阅读

共计 877 个字符,预计需要花费 3 分钟才能阅读完成。

创立工程,引入依赖

<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-elasticsearch</artifactId>
<!--<version>2.1.5.RELEASE</version>-->
<version>2.2.2.RELEASE</version>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>

配置 yml

spring:
data:
elasticsearch:
cluster-name: es6
cluster-nodes: 192.168.1.187:9300

版本协调
目前 springboot-data-elasticsearch 中的 es 版本贴合为 es-6.4.3,如此一来版本须要对立,把 es 进行降级。等 springboot 降级 es 版本后能够在对接最新版的 7.4。
Netty issue fix

@Configuration
public class ESConfig {
/**
* 解决 netty 引起的 issue
*/
@PostConstruct
void init() {System.setProperty("es.set.netty.runtime.available.processors", "false");
}
}

附 elasticsearch6.4.3 配置文件
elasticsearch.yml

cluster.name: es6
node.name: node0
path.data: /usr/local/elasticsearch-6.4.3/data
path.logs: /usr/local/elasticsearch-6.4.3/logs
network.host: 0.0.0.0


正文完
 0