【发布时间】:2017-04-25 01:38:30
【问题描述】:
我期待将 Elasticsearch 集成到 Spring Boot Web 应用程序中。这是创建传输客户端的配置:
@Configuration
public class ElasticsearchConfig {
private TransportClient client;
@Bean
public TransportClient client() throws UnknownHostException{
Settings settings = Settings.builder()
.put("client.transport.nodes_sampler_interval", "5s")
.put("client.transport.sniff", false)
.put("transport.tcp.compress", true)
.put("cluster.name", "clusterName")
.put("xpack.security.transport.ssl.enabled", true)
.build();
client = new PreBuiltTransportClient(settings);
client.addTransportAddress(new InetSocketTransportAddress(InetAddress.getByName("localhost"), 9300));
return client;
}
当我启动项目时,我收到以下错误,我不知道为什么:
java.lang.ClassNotFoundException: org.elasticsearch.plugins.NetworkPlugin
我忘记添加依赖了吗?
<dependency>
<groupId>org.springframework.data</groupId>
<artifactId>spring-data-elasticsearch</artifactId>
</dependency>
<dependency>
<groupId>org.elasticsearch.client</groupId>
<artifactId>transport</artifactId>
<version>5.1.1</version>
</dependency>
希望你能帮助我
【问题讨论】:
标签: spring elasticsearch spring-boot client transport