1.引入依赖
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-elasticsearch</artifactId>
<version>2.2.2.RELEASE</version>
</dependency>
2.配置yml文件
spring:
data:
elasticsearch:
cluster-name: es6
cluster-nodes: 192.168.3.50:9300,192.168.3.51:9300
3.启动可能由于netty issue报错 解决!
@Configuration
public class ESConfig {
/** * 解决netty引起的issue */
@PostConstruct
void init(){
System.setProperty("es.set.netty.runtime.available.processors", "false");
}
}
4.接下来就可以使用了