我用的是ElasticSearch 5.2的版本,对应的客户端也是5.2的
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.(AbstractComponent.java:37)
at org.elasticsearch.plugins.PluginsService.(PluginsService.java:98)
at org.elasticsearch.client.transport.TransportClient.newPluginService(TransportClient.java:99)
at org.elasticsearch.cli