1

SpringBoot 1.4 で Jest 0.0.6 ElasticSearch クライアントを使用しようとしていますが、次のエラーが発生します。これは、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 を使用できます。」

4

1 に答える 1

1

このjest githubページで見つけました。es 0.90.5 を使用する場合は、jest 0.0.6. そして、Spring Boot の依存関係の親があり、jest のバージョンを次のように指定します2.0.3

<jest.version>2.0.3</jest.version>

そして、自動設定コード:org.springframework.boot.autoconfigure.elasticsearch.jest.JestAutoConfiguration

この自動構成クラスはio.searchbox.client.JestClient、クラスパスに追加されるとロードされます。

これはConditionフレームごとの実装です: @ConditionalOnClass(JestClient.class).

条件フレームワークの詳細については、こちらをご覧ください

開始クラスに除外を追加して、この自動構成を除外します。

import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.autoconfigure.elasticsearch.jest.JestAutoConfiguration;
import org.springframework.boot.autoconfigure.jdbc.DataSourceAutoConfiguration;

@SpringBootApplication
@EnableAutoConfiguration(exclude = { JestAutoConfiguration.class})
public class App {

    public static void main(String[] args) {
        SpringApplication.run(App.class, args);
    }
}

この除外を追加した後、クラスを起動します。所有する jest クライアントを構成できます。

于 2016-11-09T05:06:47.617 に答える