我使用Lucene的4.0,我想以这种方式创建一个新的indexWriter
:创造新的Lucene索引中没有找到类错误
IndexWriter index = LuceneUtils.createIndexWriter(indexPath, true);
(它的工作使用Lucene 3.6) 其中indexPath
是String
与索引的路径。我得到这个错误:
Exception in thread "main" java.lang.NoClassDefFoundError: org/apache/lucene/analysis/SimpleAnalyzer
at lucene.IndexCreator.<init>(IndexCreator.java:25)
at main.Main.main(Main.java:72)
Caused by: java.lang.ClassNotFoundException: org.apache.lucene.analysis.SimpleAnalyzer
at java.net.URLClassLoader$1.run(URLClassLoader.java:202)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:190)
at java.lang.ClassLoader.loadClass(ClassLoader.java:306)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:301)
at java.lang.ClassLoader.loadClass(ClassLoader.java:247)
... 2 more
我已阅读,我需要添加lucene-analyzers-common-4.0.0.jar
到项目之外lucene-core-4.0.0.jar
,但我得到了同样的错误。 其实012ath里的SimpleAnalyzer.class
的路径不是org.apache.lucene.analysis.SimpleAnalyzer
而是org.apache.lucene.analysis.core.SimpleAnalyzer
。
MVN依赖性:树将做的工作,如果使用Maven的。 –
如果使用Gradle,则使用'gradle dependencies'。 –