# Question about Spring Data Elasticsearch using Rest Client

**URL:** <https://discuss.elastic.co/t/question-about-spring-data-elasticsearch-using-rest-client/222886>\
**Category:** Elasticsearch\
**Created:** [March 10, 2020, 8:48am UTC](https://discuss.elastic.co/t/question-about-spring-data-elasticsearch-using-rest-client/222886 "2020-03-10T08:48:25Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![aiden\_elastic](https://avatars.discourse-cdn.com/v4/letter/a/d6d6ee/32.png) [@aiden\_elastic](https://discuss.elastic.co/u/aiden_elastic)\
**Post date:** [March 10, 2020, 8:48am UTC](https://discuss.elastic.co/t/question-about-spring-data-elasticsearch-using-rest-client/222886/1 "2020-03-10T08:48:25Z")

</div>

I am trying to connect spring data elastic search with elastic search using Rest Client.

This is pom.xml

```
<?xml version="1.0" encoding="UTF-8"?>
   <project xmlns="http://maven.apache.org/POM/4.0.0" 
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 
    https://maven.apache.org/xsd/maven-4.0.0.xsd">
    <modelVersion>4.0.0</modelVersion>
    <parent>
	    <groupId>org.springframework.boot</groupId>
	    <artifactId>spring-boot-starter-parent</artifactId>
	    <version>2.2.5.RELEASE</version>
	    <relativePath/> <!-- lookup parent from repository -->
    </parent>
    <groupId>com.example</groupId>
    <artifactId>SpringData</artifactId>
    <version>0.0.1-SNAPSHOT</version>
    <name>SpringData</name>
    <description>Demo project for Spring Boot</description>

    <repositories>
        <repository>
            <id>elastic-lucene-snapshots</id>
            <name>Elastic Lucene Snapshots</name>
       <url>http://s3.amazonaws.com/download.elasticsearch.org/lucenesnapshots/00142c9</url>
        <releases><enabled>true</enabled></releases>
        <snapshots><enabled>false</enabled></snapshots>
        </repository>
    </repositories>

    <properties>
    	<java.version>1.8</java.version>
        <elasticsearch.version>6.4.3</elasticsearch.version>
    </properties>

    <dependencies>
    	<dependency>
	    	<groupId>org.springframework.boot</groupId>
		    <artifactId>spring-boot-starter</artifactId>
	    </dependency>

	    <dependency>
		    <groupId>org.springframework.boot</groupId>
		    <artifactId>spring-boot-starter-test</artifactId>
		    <scope>test</scope>
		    <exclusions>
			    <exclusion>
				    <groupId>org.junit.vintage</groupId>
				    <artifactId>junit-vintage-engine</artifactId>
			    </exclusion>
		    </exclusions>
	    </dependency>
	
	    <!-- REST Client -->
        <dependency>
            <groupId>org.elasticsearch.client</groupId>
            <artifactId>elasticsearch-rest-high-level-client</artifactId>
            <version>${elasticsearch.version}</version><!--$NO-MVN-MAN-VER$-->
        </dependency>
    
        <!-- 좌표계산 -->
	    <dependency>
	        <groupId>org.locationtech.spatial4j</groupId>
	        <artifactId>spatial4j</artifactId>
	        <version>0.7</version>                        
	    </dependency>
	
	    <dependency>
	        <groupId>org.locationtech.jts</groupId>
	        <artifactId>jts-core</artifactId>
	        <version>1.15.0</version>                         
	        <exclusions>
	            <exclusion>
	                <groupId>xerces</groupId>
	                <artifactId>xercesImpl</artifactId>
	            </exclusion>
	        </exclusions>
	    </dependency>
	
	    <!-- log4j -->
	    <dependency>
		    <groupId>org.apache.logging.log4j</groupId>
		    <artifactId>log4j-api</artifactId>
		    <version>2.13.0</version><!--$NO-MVN-MAN-VER$-->
	    </dependency>
	
	    <!-- log4j-core -->
	    <dependency>
		    <groupId>org.apache.logging.log4j</groupId>
		    <artifactId>log4j-core</artifactId>
		    <version>2.13.0</version><!--$NO-MVN-MAN-VER$-->
	    </dependency>        
	
	    <!-- Spring Data -->
	    <dependency>
		    <groupId>org.springframework.data</groupId>
		    <artifactId>spring-data-elasticsearch</artifactId>
		    <version>3.1.0.RELEASE</version><!--$NO-MVN-MAN-VER$-->
	    </dependency>
    </dependencies>

    <build>
	    <plugins>
		    <plugin>
			    <groupId>org.springframework.boot</groupId>
			    <artifactId>spring-boot-maven-plugin</artifactId>
		    </plugin>
	    </plugins>
    </build>

</project>

```

And this is my problem

```
package com.example.demo;

import static org.elasticsearch.common.xcontent.XContentFactory.jsonBuilder;

import java.io.IOException;

import org.apache.http.HttpHost;
import org.elasticsearch.action.admin.indices.alias.Alias;
import org.elasticsearch.action.admin.indices.create.CreateIndexRequest;
import org.elasticsearch.action.admin.indices.create.CreateIndexResponse;
import org.elasticsearch.client.RequestOptions;
import org.elasticsearch.client.RestClient;
import org.elasticsearch.client.RestHighLevelClient;
import org.elasticsearch.common.xcontent.XContentBuilder;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

@Configuration
public class EsConfig extends AbstractElasticsearchConfiguration {

@Override
@Bean
public RestHighLevelClient elasticsearchClient() {

    final ClientConfiguration clientConfiguration = ClientConfiguration.builder()
        .connectedTo("localhost:9200")
        .build();

    return RestClients.create(clientConfiguration).rest();
   }
}

```

I referenced this code in [https://github.com/spring-projects/spring-data-elasticsearch](https://github.com/spring-projects/spring-data-elasticsearch) but  
STS tells `AbstractElasticsearchConfiguration cannot be resolved to a type`.

To solve, I took the`AbstractElasticsearchConfiguration` code from github and pasted it directly into my project.

Is this problem caused by version collision?

This question is irrelevant, but I want to create web pages using Spring and Elastic Search. I wonder if it's common to use spring mvc or spring boot. Furthermore, is there any docs or site to help me create web pages using elasticsearch and spring?

---

<div class="post-metadata">

**Author:** ![dadoonet](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/dadoonet/32/137187_2.png) [@dadoonet](https://discuss.elastic.co/u/dadoonet)\
**Post date:** [March 10, 2020, 9:05am UTC](https://discuss.elastic.co/t/question-about-spring-data-elasticsearch-using-rest-client/222886/2 "2020-03-10T09:05:13Z")

</div>

And? What is the question?

When using springboot with elasticsearch, you need to be explicit with some transitive dependencies as SpringBoot declares a version 6.4...

Basically you can put this in your `pom.xml`:

```auto
<properties>
  <elasticsearch.version>7.6.1<elasticsearch.version>
</properties>

```

See documentation here: [https://docs.spring.io/spring-boot/docs/current/reference/html/howto.html#howto-customize-dependency-versions](https://docs.spring.io/spring-boot/docs/current/reference/html/howto.html#howto-customize-dependency-versions)

---

<div class="post-metadata">

**Author:** ![aiden\_elastic](https://avatars.discourse-cdn.com/v4/letter/a/d6d6ee/32.png) [@aiden\_elastic](https://discuss.elastic.co/u/aiden_elastic)\
**Post date:** [March 10, 2020, 10:01am UTC](https://discuss.elastic.co/t/question-about-spring-data-elasticsearch-using-rest-client/222886/3 "2020-03-10T10:01:57Z")

</div>

Oh, thank you for answering.  
I will try to use properties in my pom.xml  
Even if I revised pom.xml, the error occurs again.

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/elastic/original/3X/1/a/1ac57faf039f6b580b3f104ef42a2a89e41014de.png) [@system](https://discuss.elastic.co/u/system)\
**Post date:** [April 7, 2020, 10:08am UTC](https://discuss.elastic.co/t/question-about-spring-data-elasticsearch-using-rest-client/222886/4 "2020-04-07T10:08:09Z")

</div>

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