2016-09-09 7 views
1

SpringBoot 1.4でJest 0.0.6 ElasticSearchクライアントを使用しようとしていて、次のエラーがあります。私はSpringBootがJest Clientをヘルスチェックとともに自動的に作成しようとしているのだが、古いJestクライアントには必要なクラスがいくつかあるからだと思う。Springboot 1.4 + Jest 0.0.6

どのようにすればいいですか?

この時点でアップグレードするオプションがない古いElasticSearch v0.90.5サーバーに接続する必要があります。 SpringBooの古いバージョンに接続するには、どのように最善の方法をとっているかについてのアイデアがあれば、それも非常に役に立ちます。

冗談サポート

は春ブーツが自動設定さJestClientと専用HealthIndicator冗談はクラスパス上にある場合、これはあなたがすることができます。春ブーツ1.4リリースノートから

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-data-elasticsearchがclasspathにない場合でもElasticsearchを使用してください。

+0

pomまたはgradleビルドファイルにアクチュエータの依存関係を含めてください。このリンクhttp://start.spring.ioでアプリケーションをブートストラップすることをお勧めします。 –

+0

この変更の前にアクチュエータは正常に動作していましたが、欠席しているクラスはJestライブラリからのものです。 – chrismacp

答えて

1

このjest githubページに見つかりました。 es 0.90.5を使用する場合は、jest 0.0.6を使用する必要があります。そして、春のブート依存関係親が冗談のバージョンを指定し、そこにあることは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); 
    } 
} 

をした後、あなたがクラスを起動するには、この除外を追加:

あなたは、クラスを起動するために除外し、追加することによって、この自動設定を除外する条件の枠組みhere

についての詳細を見つけることができます。自分の所有するjestクライアントを設定することができます。

+0

情報をありがとう、私はそれがもはやこの問題を抱えていないので、それが壊れ始めた後、ESのアップグレードのための承認を得ることができました。多分誰かがこれを見てそれをテストします。 – chrismacp

+0

@EnableAutoConfigurationアノテーションのexcludeが私のために働いていました。 –