我想运行以下java代码:
import java.util.Map; import org.elasticsearch.action.get.GetResponse; import org.elasticsearch.client.Client; import org.elasticsearch.node.Node; import static org.elasticsearch.node.NodeBuilder.*; public class MongoDB { public static void main(String[] args) { Node node = nodeBuilder().clusterName("elasticsearch").client(true).node(); Client client = node.client(); node.close(); } }
我用以下命令运行mongod:
mongod --port 27017 --replSet rs0
带有默认conf的Elasticsearch
每次我运行我的程序时都会出现以下错误:
Exception in thread "main" java.lang.NoClassDefFoundError: org/apache/lucene/util/Version at org.elasticsearch.Version.(Version.java:42) at org.elasticsearch.Version. (Version.java:42) at org.elasticsearch.node.internal.InternalNode. (InternalNode.java:129) at org.elasticsearch.node.NodeBuilder.build(NodeBuilder.java:159) at org.elasticsearch.node.NodeBuilder.node(NodeBuilder.java:166) at org.elasticsearch.river.mongodb.MongoDB.main(MongoDB.java:10) Caused by: java.lang.ClassNotFoundException: org.apache.lucene.util.Version at java.net.URLClassLoader$1.run(URLClassLoader.java:366) at java.net.URLClassLoader$1.run(URLClassLoader.java:355) at java.security.AccessController.doPrivileged(Native Method) at java.net.URLClassLoader.findClass(URLClassLoader.java:354) at java.lang.ClassLoader.loadClass(ClassLoader.java:425) at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:308) at java.lang.ClassLoader.loadClass(ClassLoader.java:358) ... 5 more Java Result: 1
Hardik Bhala.. 8
Elasticsearch
是一个基于的搜索服务器Lucene
.你必须包含lucene jar文件lucene-core-x.x.x.jar
和其他相关的jar文件才能使这段代码正常工作......
Elasticsearch
是一个基于的搜索服务器Lucene
.你必须包含lucene jar文件lucene-core-x.x.x.jar
和其他相关的jar文件才能使这段代码正常工作......