springboot 集成es7.x在启动时报错,错误内容如下:
java.net.ConnectException: Timeout connecting to [localhost/127.0.0.1:9200]
原因是因为es开启了健康检查,默认连接的地址是 http://localhost:9200
找到es源码 RestClientProperties类
解决办法:
我们只要修改源码里面的prefix的配置即可,指向自己的服务
# 修改es健康检查地址
spring.elasticsearch.rest.uris= ["http://172.16.8.44:9200"]
参考地址:http://blog.joylau.cn/2019/01/16/SpringBoot-Elasticsearch-HealthCheck/