# Maven dependencies with elasticsearch

**URL:** <https://discuss.elastic.co/t/maven-dependencies-with-elasticsearch/76220>\
**Category:** Elasticsearch\
**Created:** [February 23, 2017, 1:22pm UTC](https://discuss.elastic.co/t/maven-dependencies-with-elasticsearch/76220 "2017-02-23T13:22:48Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![zegdene](https://avatars.discourse-cdn.com/v4/letter/z/76d3ee/32.png) [@zegdene](https://discuss.elastic.co/u/zegdene)\
**Post date:** [February 23, 2017, 1:22pm UTC](https://discuss.elastic.co/t/maven-dependencies-with-elasticsearch/76220/1 "2017-02-23T13:22:48Z")

</div>

hello,  
i'm new with elasticsearch and i'm trying to make a java application that will allow me to communicate with a cluster elasticsearch . i started with creating a maven project and in the pom.xml i have put in my pom.xml the code bellow:

> `<dependency> <groupId>org.elasticsearch</groupId> <artifactId>elasticsearch</artifactId> <version>2.3.3</version> </dependency>`

in the main class i have put

```
> import org.elasticsearch.client.Client;
> import org.elasticsearch.client.transport.TransportClient;
> import org.elasticsearch.common.transport.InetSocketTransportAddress;
> import org.elasticsearch.index.query.SimpleQueryParser.Settings;
> import org.springframework.context.annotation.Bean;
> import org.springframework.context.annotation.Configuration;
> import org.springframework.context.annotation.PropertySource;
> import org.springframework.core.env.Environment;
> import org.springframework.data.elasticsearch.core.ElasticsearchOperations;
> import org.springframework.data.elasticsearch.core.ElasticsearchTemplate;
> import org.springframework.data.elasticsearch.repository.config.EnableElasticsearchRepositories;

> import javax.annotation.Resource;

> @Configuration
> @PropertySource(value = "classpath:elasticsearch.properties")
> @EnableElasticsearchRepositories(basePackages = "com.biganalytics.project.repositories")
> public class ElasticsearchConfiguration {
> @Resource
> private Environment environment;
> @Bean
> public Client client() {
> Client client = new TransportClient()
> TransportAddress address = new InetSocketTransportAddress(environment.getProperty("elasticsearch.host"), Integer.parseInt(environment.getProperty("elasticsearch.port")));
> client.addTransportAddress(address);
> }
>    
> @Bean
> public ElasticsearchOperations elasticsearchTemplate() {
> return new ElasticsearchTemplate(client());
> }
> }

```

but this class didn't work and i have errors :The constructor InetSocketTransportAddress(String, int) is undefined and The method addTransportAddress(TransportAddress) is undefined for the type Client

can anyone tell me what is the problem  
thanks a lot

---

<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:** [February 23, 2017, 4:43pm UTC](https://discuss.elastic.co/t/maven-dependencies-with-elasticsearch/76220/2 "2017-02-23T16:43:29Z")

</div>

May be you are mixing some versions of elasticsearch in your project?  
Sounds like you are using Spring, right? May be run a `mvn dependency:tree` would help?

---

<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:** [March 23, 2017, 4:43pm UTC](https://discuss.elastic.co/t/maven-dependencies-with-elasticsearch/76220/3 "2017-03-23T16:43:28Z")

</div>

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