Can't create transport client for elasticsearch 5.2.2

My build.gradle:

dependencies {
    compile('org.elasticsearch.client:transport:5.2.2')
    compile('org.elasticsearch:elasticsearch:5.2.2')
}

And like the tutorial, I create my transport client like this:

Settings settings = Settings.builder().put("cluster.name", "es").build();
TransportClient client = new PreBuiltTransportClient(settings).addTransportAddress(new InetSocketTransportAddress(InetAddress.getByName("http://10.19.132.207"), 9300));

When I run the code. It has error like:

Caused by: java.lang.NoSuchMethodError: org.elasticsearch.common.settings.Settings.settingsBuilder()Lorg/elasticsearch/common/settings/Settings$Builder;
	at org.springframework.boot.autoconfigure.data.elasticsearch.ElasticsearchAutoConfiguration.createNodeClient(ElasticsearchAutoConfiguration.java:99)
	at org.springframework.boot.autoconfigure.data.elasticsearch.ElasticsearchAutoConfiguration.createClient(ElasticsearchAutoConfiguration.java:95)
	at org.springframework.boot.autoconfigure.data.elasticsearch.ElasticsearchAutoConfiguration.elasticsearchClient(ElasticsearchAutoConfiguration.java:84)
	at org.springframework.boot.autoconfigure.data.elasticsearch.ElasticsearchAutoConfiguration$$EnhancerBySpringCGLIB$$3463d1cb.CGLIB$elasticsearchClient$1(<generated>)
	at org.springframework.boot.autoconfigure.data.elasticsearch.ElasticsearchAutoConfiguration$$EnhancerBySpringCGLIB$$3463d1cb$$FastClassBySpringCGLIB$$f822f370.invoke(<generated>)
	at org.springframework.cglib.proxy.MethodProxy.invokeSuper(MethodProxy.java:228)
	at org.springframework.context.annotation.ConfigurationClassEnhancer$BeanMethodInterceptor.intercept(ConfigurationClassEnhancer.java:358)
	at org.springframework.boot.autoconfigure.data.elasticsearch.ElasticsearchAutoConfiguration$$EnhancerBySpringCGLIB$$3463d1cb.elasticsearchClient(<generated>)
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at java.lang.reflect.Method.invoke(Method.java:498)
	at org.springframework.beans.factory.support.SimpleInstantiationStrategy.instantiate(SimpleInstantiationStrategy.java:162)
	... 47 more

How to resolve this problem?

You need to solve it on Spring side.
This version of Spring calls a 2.x method.

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.