Elastic Search 6.5.1 集成 Java 客户端连接时,在网上找了解决方案还是不行,求助

public static void main(String[] args) throws UnknownHostException {
String hostName = “”;
TransportAddress transportAddress = new TransportAddress(InetAddress.getByName(hostName), );
String clusterName = “”;
String nodeName = “”;
Settings settings = Settings.builder().put(clusterName, nodeName).build();
TransportClient client = new PreBuiltTransportClient(settings);
client.addTransportAddress(transportAddress);
System.out.println(client);
client.close();
}
报错信息:
19:07:43.771 [main] DEBUG io.netty.util.internal.PlatformDependent - -Dio.netty.maxDirectMemory: -1 bytes
19:07:43.771 [main] DEBUG io.netty.util.internal.PlatformDependent - -Dio.netty.uninitializedArrayAllocationThreshold: -1
19:07:43.773 [main] DEBUG io.netty.util.internal.CleanerJava6 - java.nio.ByteBuffer.cleaner(): available
19:07:43.774 [main] DEBUG io.netty.util.internal.PlatformDependent - -Dio.netty.noPreferDirect: false
Exception in thread “main” java.lang.reflect.InvocationTargetException
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at com.intellij.rt.execution.CommandLineWrapper.main(CommandLineWrapper.java:67)
Caused by: java.lang.NoSuchMethodError: org.elasticsearch.common.logging.Loggers.getLogger(Ljava/lang/Class;)Lorg/apache/logging/log4j/Logger;
at org.elasticsearch.percolator.PercolatorFieldMapper.(PercolatorFieldMapper.java:106)
at org.elasticsearch.percolator.PercolatorPlugin.getSettings(PercolatorPlugin.java:60)
at org.elasticsearch.plugins.PluginsService.lambda$getPluginSettings$0(PluginsService.java:89)
at java.util.stream.ReferencePipeline$7$1.accept(ReferencePipeline.java:267)
at java.util.ArrayList$ArrayListSpliterator.forEachRemaining(ArrayList.java:1374)
at java.util.stream.AbstractPipeline.copyInto(AbstractPipeline.java:481)
at java.util.stream.AbstractPipeline.wrapAndCopyInto(AbstractPipeline.java:471)
at java.util.stream.ReduceOps$ReduceOp.evaluateSequential(ReduceOps.java:708)
at java.util.stream.AbstractPipeline.evaluate(AbstractPipeline.java:234)
at java.util.stream.ReferencePipeline.collect(ReferencePipeline.java:499)
at org.elasticsearch.plugins.PluginsService.getPluginSettings(PluginsService.java:89)
at org.elasticsearch.client.transport.TransportClient.buildTemplate(TransportClient.java:147)
at org.elasticsearch.client.transport.TransportClient.(TransportClient.java:288)
at org.elasticsearch.transport.client.PreBuiltTransportClient.(PreBuiltTransportClient.java:128)
at org.elasticsearch.transport.client.PreBuiltTransportClient.(PreBuiltTransportClient.java:114)
at org.elasticsearch.transport.client.PreBuiltTransportClient.(PreBuiltTransportClient.java:104)
at com.sjky.platform.manager.util.Es1Application.main(Es1Application.java:18)
… 5 more

最佳答案

试一下 elasticsearch-rest-high-level-client,官方推荐的 java 客户端。transport 将计划在后面的版本中废弃。

1个月前 评论
lxj123456 (楼主) 1个月前
讨论数量: 1

试一下 elasticsearch-rest-high-level-client,官方推荐的 java 客户端。transport 将计划在后面的版本中废弃。

1个月前 评论
lxj123456 (楼主) 1个月前

请勿发布不友善或者负能量的内容。与人为善,比聪明更重要!