Я хочу использовать ElasticSearch с Spring Data. Я использую Spring 5, Spring Boot 2 и ElasticSearch 7.4. Docker -компонент:
version: '2.1'
services:
elasticsearch:
container_name: "elasticsearch"
image: docker.elastic.co/elasticsearch/elasticsearch:7.4.0
volumes:
- ./docker-data/elasticsearch/config/elasticsearch.yml:/usr/share/elasticsearch/config/elasticsearch.yml:ro
ports:
- 9200:9200
- 9300:9300
expose:
- 9200
- 9300
environment:
- discovery.type=single-node
networks:
- elastic
kibana:
image: docker.elastic.co/kibana/kibana:7.4.2
container_name: kibana
volumes:
- ./docker-data/kibana/config/kibana.yml:/usr/share/kibana/config/kibana.yml:ro
ports:
- 5601:5601
networks:
- elastic
depends_on:
- elasticsearch
maven:
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-elasticsearch</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.data</groupId>
<artifactId>spring-data-elasticsearch</artifactId>
<version>3.2.4.RELEASE</version>
</dependency>
Репозиторий:
@Repository
public interface AddressElasticRepository extends ElasticsearchRepository<Address, String> {
}
@Data
@Document(indexName = "fias", type = "address")
public class Address {
@Id
private String id;
private String fullAddress;
}
Конфиг:
import org.elasticsearch.client.RestHighLevelClient;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.data.elasticsearch.client.ClientConfiguration;
import org.springframework.data.elasticsearch.client.RestClients;
import org.springframework.data.elasticsearch.core.ElasticsearchRestTemplate;
import org.springframework.data.elasticsearch.repository.config.EnableElasticsearchRepositories;
@Configuration
@EnableElasticsearchRepositories
public class Config {
@Bean
RestHighLevelClient elasticsearchClient() {
final ClientConfiguration configuration = ClientConfiguration.builder()
.connectedTo("localhost:9200")
.build();
return RestClients.create(configuration).rest();
}
@Bean
ElasticsearchRestTemplate elasticsearchTemplate() {
return new ElasticsearchRestTemplate(elasticsearchClient());
}
}
И ошибка при запуске приложения:
Причина: java .lang.NoSuchMethodError: org.springframework.http.HttpHeaders. (Lorg / springframework / util / MultiValueMap;) V
Ошибка возникает в методе Config :: asticsearchClient в строке: .build ();
Что не так?