Java 库类无法识别?
导入以下内容:
import org.apache.lucene.analysis.PorterStemmer
我正在Java 程序中 整个包可以在参考库中找到。
我尝试导入
import org.apache.lucene.analysis.PorterStemFilter
,
import org.apache.lucene.analysis.Analyzer;
除了提到的第一个之外,两者都工作正常 有人能指出原因吗?!
I am importing this following :
import org.apache.lucene.analysis.PorterStemmer
in Java program. The whole package is available in refrenced library.
I tried importing
import org.apache.lucene.analysis.PorterStemFilter
and
import org.apache.lucene.analysis.Analyzer;
both are working fine except the first one mentioned
Can anybody point out why ?!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
包 org.apache.lucene.analysis.PorterStemmer 不是公共包,这就是您无法导入它的原因。如果您在库中查看此包,您会发现它以
class PorterStemmer
开头,而不是public class PorterStemmer
。Package
org.apache.lucene.analysis.PorterStemmer
is not a public package which is why you cannot import it. If you look at this package inside the library, you'll notice that it begins withclass PorterStemmer
instead ofpublic class PorterStemmer
.我的猜测是您有一个不同版本的 Lucene JAR,它不包含无法工作的类。使用 WinZip、7Zip 或其他工具打开 JAR,看看该类是否确实丢失。如果是,您要么需要找到包含它的 JAR 版本,要么重写代码以使用替代方案。
My guess is that you have a different version of the Lucene JAR that doesn't contain the class that's failing to work. Open the JAR with WinZip, 7Zip, or some other tool and see if that class is indeed missing. If it is, you either need to find a version of the JAR that has it or rewrite your code to use an alternative.