我的 spring-boot(版本 2.4.1)应用程序已使用自动连接的 org.elasticsearch.client.RestHighLevelClient 成功连接到 ElasticSearch(v7.9.3)实例(我只需指定应用程序属性并且它可以工作)。
在项目的新阶段,添加了对 spring-boot-starter-webflux 的依赖,以使用一些反应式逻辑来调用外部 Web 服务。 (这与我的elasticsearch连接无关)
但现在突然elasticsearch客户端也尝试使用reactor进行连接,我收到了如下错误:
reactor.core.Exceptions$ErrorCallbackNotImplemented: org.springframework.data.elasticsearch.client.NoReachableHostException:
Host 'https://elastic-dev.company.intra:9200:9200' not reachable. Cluster state is offline.
Caused by: org.springframework.data.elasticsearch.client.NoReachableHostException:
Host 'https://elastic-dev.company.intra:9200:9200' not reachable. Cluster state is offline.
at org.springframework.data.elasticsearch.client.reactive.SingleNodeHostProvider.lambda$lookupActiveHost$4(SingleNodeHostProvider.java:108) ~[spring-data-elasticsearch-4.1.2.jar!/:4.1.2]
我知道 :9200:9200 存在配置问题,但我想禁用我的 Elasticsearch 客户端的reactor,以便它只使用旧的方式(我仍然需要我的 Elasticseach 客户端)。这可能吗 ?
Thanks.
进一步搜索后,我找到了 P.J.Meish 也建议的解决方案:禁用有关反应式 elasticsearch 的 AutoConfiguration 类:
我更喜欢 application.properties 中的配置:
spring.autoconfigure.exclude=\
org.springframework.boot.actuate.autoconfigure.elasticsearch.ElasticSearchReactiveHealthContributorAutoConfiguration,\
org.springframework.boot.autoconfigure.data.elasticsearch.ReactiveElasticsearchRepositoriesAutoConfiguration,\
org.springframework.boot.autoconfigure.data.elasticsearch.ReactiveElasticsearchRestClientAutoConfiguration
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)