【发布时间】:2016-09-09 11:20:01
【问题描述】:
我正在尝试将 Jest 0.0.6 ElasticSearch 客户端与 SpringBoot 1.4 一起使用,但出现以下错误。我认为这是因为 SpringBoot 尝试自动创建一个 Jest 客户端并对其进行健康检查,但旧的 Jest 客户端没有一些必需的类。
任何想法如何解决这个问题?
我需要连接到旧的 ElasticSearch v0.90.5 服务器,目前我无法升级。如果您对如何最好地从 SpringBoot 连接到这样一个旧版本有任何想法,那也将非常有帮助。
Caused by:org.springframework.beans.factory.UnsatisfiedDependencyException:
Error creating bean with name 'metricsEndpointMetricReader' defined in class path resource
...
[org/springframework/boot/actuate/autoconfigure/ElasticsearchHealthIndicatorConfiguration$ElasticsearchJestHealthIndicatorConfiguration.class]:
Bean instantiation via factory method failed; nested exception is org.springframework.beans.BeanInstantiationException: Failed to instantiate [org.springframework.boot.actuate.health.HealthIndicator]:
Factory method 'elasticsearchHealthIndicator' threw exception; nested exception is java.lang.NoClassDefFoundError: io/searchbox/action/Action; nested exception is
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'org.springframework.boot.actuate.autoconfigure.EndpointAutoConfiguration ': Bean instantiation via constructor failed; nested exception is
org.springframework.beans.BeanInstantiationException: Failed to instantiate [org.springframework.boot.actuate.autoconfigure.EndpointAutoConfiguration$$EnhancerBySpringCGLIB$$909d8b5d]: Constructor threw exception; nested exception is org.springframework.beans.factory.BeanCreationException:
Error creating bean with name 'elasticsearchHealthIndicator' defined in class path resource [org/springframework/boot/actuate/autoconfigure/ElasticsearchHealthIndicatorConfiguration$ElasticsearchJestHealthIndicatorConfiguration.class]: Bean instantiation via factory method failed; nested exception is
org.springframework.beans.BeanInstantiationException: Failed to instantiate [org.springframework.boot.actuate.health.HealthIndicator]: Factory method 'elasticsearchHealthIndicator' threw exception; nested exception is java.lang.NoClassDefFoundError: io/searchbox/action/Action
来自 Spring Boot 1.4 发行说明:
"笑话支持
如果 Jest 在类路径上,Spring Boot 会自动配置一个 JestClient 和一个专用的 HealthIndicator。即使 spring-data-elasticsearch 不在类路径中,这也允许您使用 Elasticsearch。”
【问题讨论】:
-
请在 pom 或 gradle 构建文件中包含执行器依赖项。我建议使用此链接 start.spring.io 来引导您的应用程序。
-
执行器在此更改之前都正常工作,缺少的类来自 Jest 库所以不知道如何解决它?
标签: java spring-boot elasticsearch-jest