gpt4 book ai didi

java - 使用 Spring Boot 的 Elasticsearch 无法正常工作

转载 作者:行者123 更新时间:2023-11-29 10:11:03 26 4
gpt4 key购买 nike

我是 elasticsearch 的新手,我想将我使用 Springboot (1.3.1.RELEASE) 开发的 web 应用程序连接到安装在 unix VM 中的远程 Elasticsearch 实例,因此我将以下内容添加到我的 pom.xml 文件中。 XML

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

这是我application.yml中的配置

 spring:
data:
elasticsearch:
host: 192.168.56.101
port: 9300
cluster-nodes: 192.168.56.101:9300

但我遇到以下异常:

2015-12-20 23:26:58.621  INFO 8580 --- [on(3)-127.0.0.1]    o.s.d.e.c.TransportClientFactoryBean     : adding transport node :   192.168.56.101:9300
2015-12-20 23:26:58.710 WARN 8580 --- [ I/O worker #1}] org.elasticsearch.transport.netty : [Coldfire] Message not fully read (response) for [0] handler future(org.elasticsearch.client.transport.TransportClientNodesService$SimpleNodeSampler$1@54acdf57), error [true], resetting
2015-12-20 23:26:58.717 INFO 8580 --- [on(3)-127.0.0.1] org.elasticsearch.client.transport : [Coldfire] failed to get node info for [#transport#-1][fgonzalez-HP][inet[/192.168.56.101:9300]], disconnecting...

org.elasticsearch.transport.RemoteTransportException: Failed to deserialize exception response from stream
Caused by: org.elasticsearch.transport.TransportSerializationException: Failed to deserialize exception response from stream
at org.elasticsearch.transport.netty.MessageChannelHandler.handlerResponseError(MessageChannelHandler.java:176) ~[elasticsearch-1.5.2.jar:na]
at org.elasticsearch.transport.netty.MessageChannelHandler.messageReceived(MessageChannelHandler.java:128) ~[elasticsearch-1.5.2.jar:na]
at org.elasticsearch.common.netty.channel.SimpleChannelUpstreamHandler.handleUpstream(SimpleChannelUpstreamHandler.java:70) ~[elasticsearch-1.5.2.jar:na]
at org.elasticsearch.common.netty.channel.DefaultChannelPipeline.sendUpstream(DefaultChannelPipeline.java:564) ~[elasticsearch-1.5.2.jar:na]
at org.elasticsearch.common.netty.channel.DefaultChannelPipeline$DefaultChannelHandlerContext.sendUpstream(DefaultChannelPipeline.java:791) ~[elasticsearch-1.5.2.jar:na]
at org.elasticsearch.common.netty.channel.Channels.fireMessageReceived(Channels.java:296) ~[elasticsearch-1.5.2.jar:na]
at org.elasticsearch.common.netty.handler.codec.frame.FrameDecoder.unfoldAndFireMessageReceived(FrameDecoder.java:462) ~[elasticsearch-1.5.2.jar:na]
at org.elasticsearch.common.netty.handler.codec.frame.FrameDecoder.callDecode(FrameDecoder.java:443) ~[elasticsearch-1.5.2.jar:na]
at org.elasticsearch.common.netty.handler.codec.frame.FrameDecoder.messageReceived(FrameDecoder.java:303) ~[elasticsearch-1.5.2.jar:na]
at org.elasticsearch.common.netty.channel.SimpleChannelUpstreamHandler.handleUpstream(SimpleChannelUpstreamHandler.java:70) ~[elasticsearch-1.5.2.jar:na]
at org.elasticsearch.common.netty.channel.DefaultChannelPipeline.sendUpstream(DefaultChannelPipeline.java:564) ~[elasticsearch-1.5.2.jar:na]
at org.elasticsearch.common.netty.channel.DefaultChannelPipeline.sendUpstream(DefaultChannelPipeline.java:559) ~[elasticsearch-1.5.2.jar:na]
at org.elasticsearch.common.netty.channel.Channels.fireMessageReceived(Channels.java:268) ~[elasticsearch-1.5.2.jar:na]
at org.elasticsearch.common.netty.channel.Channels.fireMessageReceived(Channels.java:255) ~[elasticsearch-1.5.2.jar:na]
at org.elasticsearch.common.netty.channel.socket.nio.NioWorker.read(NioWorker.java:88) ~[elasticsearch-1.5.2.jar:na]
at org.elasticsearch.common.netty.channel.socket.nio.AbstractNioWorker.process(AbstractNioWorker.java:108) ~[elasticsearch-1.5.2.jar:na]
at org.elasticsearch.common.netty.channel.socket.nio.AbstractNioSelector.run(AbstractNioSelector.java:337) ~[elasticsearch-1.5.2.jar:na]
at org.elasticsearch.common.netty.channel.socket.nio.AbstractNioWorker.run(AbstractNioWorker.java:89) ~[elasticsearch-1.5.2.jar:na]
at org.elasticsearch.common.netty.channel.socket.nio.NioWorker.run(NioWorker.java:178) ~[elasticsearch-1.5.2.jar:na]
at org.elasticsearch.common.netty.util.ThreadRenamingRunnable.run(ThreadRenamingRunnable.java:108) ~[elasticsearch-1.5.2.jar:na]
at org.elasticsearch.common.netty.util.internal.DeadLockProofWorker$1.run(DeadLockProofWorker.java:42) ~[elasticsearch-1.5.2.jar:na]
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142) ~[na:1.8.0_20]
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617) ~[na:1.8.0_20]
at java.lang.Thread.run(Thread.java:745) ~[na:1.8.0_20]
Caused by: java.io.StreamCorruptedException: Unsupported version: 1

有人知道这个异常的原因吗?

看起来与安装的 ElasticSearch (2.1.1) 版本不兼容。

是不是说最新版的elasticsearch不能用最新版的springboot?然后我应该降级我的 Elasticsearch 版本还是有人知道任何其他修复?

如果有帮助,这是我创建的文档:

@Document(indexName = "lng_index",type = "")
public class LanguageDoc {

@Id
private String id;

private String text;

public LanguageDoc() {
}

public LanguageDoc(String id, String text) {
this.id = id;
this.text = text;
}

public String getId() {
return id;
}

public void setId(String id) {
this.id = id;
}

public String getText() {
return text;
}

public void setText(String text) {
this.text = text;
}
}

我的 Spring Data 存储库:

@Repository
public interface LanguageRepository extends ElasticsearchRepository<LanguageDoc,String> {
}

还有 elasticsearch.yml :

# Lock the memory on startup:
#
# bootstrap.mlockall: true
#
# Make sure that the `ES_HEAP_SIZE` environment variable is set to about half the memory
# available on the system and that the owner of the process is allowed to use this limit.
#
# Elasticsearch performs poorly when the system is swapping the memory.
#
# ---------------------------------- Network ------------------------------- ----
#
# Set the bind address to a specific IP (IPv4 or IPv6):
#
# network.host: 192.168.0.1
network.host: 0.0.0.0
#
# Set a custom port for HTTP:
#
# http.port: 9200
#
# For more information, see the documentation at:
# <http://www.elastic.co/guide/en/elasticsearch/reference/current/modules- network.html>

提前感谢您的帮助!!

最佳答案

郑重声明,为了防止其他人遇到同样的问题,我已经通过将 ElasticSearch 的版本降级到 1.5.2 来修复它(与 Sprinboot 附带的内存中的 elasticSearch 实例相同)

关于java - 使用 Spring Boot 的 Elasticsearch 无法正常工作,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34386768/

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