Java连接到ElasticSearch 5.2 报错
匿名 | 发布于2017年02月07日 | 阅读数:16389
我用的是ElasticSearch 5.2的版本,对应的客户端也是5.2的
但是我执行上面的代码,往es插入数据,chux出现了这个异常
请教一下,这个问题应该要怎么解决。谢谢哈。
Settings setting = Settings.builder().put("cluster.name", "my-application").build(); TransportClient client = new PreBuiltTransportClient(setting); IndexResponse response = client.prepareIndex("blog", "article").setSource(json).get();
但是我执行上面的代码,往es插入数据,chux出现了这个异常
Exception in thread "main" java.lang.NoClassDefFoundError: org/apache/logging/log4j/Logger
at org.elasticsearch.common.logging.Loggers.getLogger(Loggers.java:105)
at org.elasticsearch.common.logging.Loggers.getLogger(Loggers.java:72)
at org.elasticsearch.common.component.AbstractComponent.<init>(AbstractComponent.java:37)
at org.elasticsearch.plugins.PluginsService.<init>(PluginsService.java:98)
at org.elasticsearch.client.transport.TransportClient.newPluginService(TransportClient.java:99)
at org.elasticsearch.client.transport.TransportClient.buildTemplate(TransportClient.java:124)
at org.elasticsearch.client.transport.TransportClient.<init>(TransportClient.java:258)
at org.elasticsearch.transport.client.PreBuiltTransportClient.<init>(PreBuiltTransportClient.java:125)
at org.elasticsearch.transport.client.PreBuiltTransportClient.<init>(PreBuiltTransportClient.java:111)
at org.elasticsearch.transport.client.PreBuiltTransportClient.<init>(PreBuiltTransportClient.java:101)
at com.water.test02.Test02.main(Test02.java:43)
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.application.AppMain.main(AppMain.java:134)
Caused by: java.lang.ClassNotFoundException: org.apache.logging.log4j.Logger
at java.net.URLClassLoader.findClass(URLClassLoader.java:381)
at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:331)
at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
... 16 more
请教一下,这个问题应该要怎么解决。谢谢哈。
6 个回复
wangjueying - Java攻城狮-ES爱好者
赞同来自: xzr15818271323
<groupId>org.apache.logging.log4j</groupId>
<artifactId>log4j-api</artifactId>
<version>2.7</version>
</dependency>
<dependency>
<groupId>org.apache.logging.log4j</groupId>
<artifactId>log4j-core</artifactId>
<version>2.7</version>
</dependency>
试试log4j2吧
lijf
赞同来自:
felayman - 专注于搜索的笨鸟
赞同来自:
<dependency>
<groupId>log4j</groupId>
<artifactId>log4j</artifactId>
<version>1.2.17</version>
</dependency>
其他含有log4j的jar包中exclude掉
zlw7741
赞同来自:
youryida - 简单的事情细心做!
赞同来自:
李远
赞同来自: