gpt4 book ai didi

spring-boot - 使用 Spring Boot 连接到 Elasticsearch 6.2.3

转载 作者:行者123 更新时间:2023-12-04 19:37:51 24 4
gpt4 key购买 nike

试图弄清楚如何让 spring boot 的工作配置连接到 Elasticsearch 6.2.3,这是我的连接代码:

pom.xml:

    <dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-elasticsearch</artifactId>
<version>2.0.1.RELEASE</version>
</dependency>

还有我的连接代码:

import org.elasticsearch.client.transport.TransportClient;
import org.elasticsearch.common.settings.Settings;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.data.elasticsearch.core.ElasticsearchTemplate;
import java.net.UnknownHostException;


@Configuration
public class ElasticsearchConfig {

@Bean
public ElasticsearchTemplate elasticsearchTemplate() throws
UnknownHostException {

Settings settings = Settings.builder()
.put("client.transport.sniff", true).build();

// Can't resolve symbol "PreBuiltTransportClient"
TransportClient client = new PreBuiltTransportClient(settings);

return new ElasticsearchTemplate(client);

}

最佳答案

现在您可以使用 6.x。无论如何,您可以在此处查看支持的版本:https://docs.spring.io/spring-data/elasticsearch/docs/3.2.0.RC3/reference/html/#preface.versions

关于spring-boot - 使用 Spring Boot 连接到 Elasticsearch 6.2.3,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/49686505/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com