简体   繁体   English

无法导入org.apache.lucene

[英]Cannot import org.apache.lucene

I wanted to use lucene library. 我想使用Lucene库。 I have downloaded it and added it as Zip file [project properties--> Libraries --> Add Jar/Folder]to my project. 我已经下载了它,并将其作为Zip文件[项目属性->库->添加Jar /文件夹]添加到我的项目中。 But I simply cannot import it. 但是我根本无法导入它。 when i type in: 当我输入:

import org.apache.lucene.analysis.Token;

it simply says package does not exist! 它只是说包不存在!

if i type 如果我输入

import org. 导入组织。

it gives me some suggestions but no apache. 它给了我一些建议,但是没有apache。

Netbeans works fine since i already imported guava.jar and using the google.common libraries. 由于我已经导入guava.jar并使用google.common库,因此Netbeans可以正常工作。

Does it has anything to do with me adding a zip as the library? 与添加zip作为库有什么关系吗? shall i do something extra after i added zip file? 添加zip文件后,我还能做些额外的事情吗? is there anywhere that i should check? 有什么地方应该检查吗?

It is easier to simply download the jar files and add them to your class path. 只需下载jar文件并将它们添加到您的类路径中,会更容易。

Note that importing only the Lucene Core jar would not work, as the Analyzers are in a separate jar named lucene-analyzers-common-{version}.jar . 请注意,仅导入Lucene Core jar无效,因为分析仪位于名为lucene-analyzers-common-{version}.jar的单独jar中。

At Maven Repository you can find the most recent versions of the Analyzers jar and the Core jar . 在Maven存储库中,您可以找到Analyzers jarCore jar的最新版本。

I think you downloaded a zip containing several lucene jar files. 我认为您下载了一个包含几个Lucene jar文件的zip文件。

That zip contains different lucenes jar files, you need to extract it and add 该zip包含不同的Lucenes jar文件,您需要将其解压缩并添加

  • core/lucene-core-4.8.0.jar 芯/ lucene的核 - 4.8.0.jar
  • analysis/common/lucene-analyzers-common-4.8.0.jar 分析/普通/ Lucene的-分析仪,共4.8.0.jar

as dependencies to your project. 作为项目的依赖项。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM