# How to configure elasticsearch 6 java

**URL:** <https://discuss.elastic.co/t/how-to-configure-elasticsearch-6-java/320652>\
**Category:** Elasticsearch\
**Tags:** language-clients\
**Created:** [December 7, 2022, 7:43am UTC](https://discuss.elastic.co/t/how-to-configure-elasticsearch-6-java/320652 "2022-12-07T07:43:35Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![aleshqo](https://avatars.discourse-cdn.com/v4/letter/a/5daacb/32.png) [@aleshqo](https://discuss.elastic.co/u/aleshqo)\
**Post date:** [December 7, 2022, 7:43am UTC](https://discuss.elastic.co/t/how-to-configure-elasticsearch-6-java/320652/1 "2022-12-07T07:43:35Z")

</div>

I'm using Spring version 2.1.18.RELEASE (I can't change this version) I need to implement a crud repository for elasticsearch, for this I connect spring-data-elasticsearch (version 3.1.21.RELEASE is automatically pulled up) with elasticsearch 6.4.3 I tried a bunch of manuals, but elastic is so different from version to version that I can't find a solution. I need to connect to remote server via https with username and password.  
pom:

```auto
        <dependency>
            <groupId>org.springframework.data</groupId>
            <artifactId>spring-data-elasticsearch</artifactId>
        </dependency>
        <dependency>
            <groupId>org.elasticsearch</groupId>
            <artifactId>elasticsearch</artifactId>
        </dependency>
        <dependency>
            <groupId>org.elasticsearch.client</groupId>
            <artifactId>transport</artifactId>
        </dependency>
        <dependency>
            <groupId>org.elasticsearch.client</groupId>
            <artifactId>elasticsearch-rest-client</artifactId>
        </dependency>

```

My config:

```auto
@Configuration
@EnableElasticsearchRepositories(basePackages = "path.to.elastic")
@ComponentScan(basePackages = {"path.to.elastic"})
public class ElasticConfiguration {

    private final int port = 1234;

    @Bean
    public Client client() throws Exception {

        Settings settings = Settings.builder().put("cluster.name", "test")
                .put("xpack.security.user", "login:pass")
                .put("xpack.security.transport.ssl.enabled", "true")
                .build();

        return new PreBuiltTransportClient(settings)
                .addTransportAddress(new TransportAddress(InetAddress.getByName("bah.elk1.com"), port))
                .addTransportAddress(new TransportAddress(InetAddress.getByName("bah.elk2.com"), port))
                .addTransportAddress(new TransportAddress(InetAddress.getByName("bah.elk3.com"), port));
    }

    @Bean
    public ElasticsearchOperations elasticsearchTemplate() throws Exception {
        return new ElasticsearchTemplate(client());
    }
}

```

This config result:

```auto
java.lang.IllegalArgumentException: unknown setting [xpack.security.user] please check that any required plugins are installed, or check the breaking changes documentation for removed settings

```

I see advice everywhere to use RestHighLevelClient, but how do I create an ElasticsearchOperations bean with it? If I add spring-data-elasticsearch 4.0.0.RELEASE I get java.lang.NoClassDefFoundError: org/springframework/data/elasticsearch/core/ElasticsearchRestTemplate

---

<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:** [January 4, 2023, 7:44am UTC](https://discuss.elastic.co/t/how-to-configure-elasticsearch-6-java/320652/2 "2023-01-04T07:44:16Z")

</div>

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