引入依赖
<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: 127.0.0.1:9300
版本协调
当前版本spring-boot-starter-data-elasticsearch中的es版本贴合6.4.3,需要Elasticsearch版本一致
Netty issue fix
@Configuration
public class ESConfig {
/**
* 解决netty引起的issue
*/
@PostConstruct
void init() {
System.setProperty("es.set.netty.runtime.available.processors", "false");
}
}