java - 从源代码: Codec does not exist构建lucene

标签 java lucene classloader

我已导入 Lucene 源并成功构建。 但是当我尝试使用任何 Lucene 类时,我得到

A SPI class of type org.apache.lucene.codecs.Codec with name 'Lucene410' does not exist
The current classpath supports the following names: []

我尝试通过以下方式获取类(class)路径

String path = Lucene410Codec.class.getProtectionDomain().getCodeSource().getLocation().toURI().getPath();

并且路径正确,因此不存在错误 jar 文件的问题。

最佳答案

问题是我在导入项目时错过了 META-INF 文件夹。 我已手动添加 META-INF/services 文件夹及其内容 - 编解码器文件(我从 lucene.core.jar 获取)到源并配置了正确的构建路径。

add something to resources in eclipse

现在我可以使用 Lucene 了。

关于java - 从源代码: Codec does not exist构建lucene,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/28576735/

相关文章:

java - Exec 任务的动态 gradle 命令失败

java - 透明度 webView

java - 如何在Java中或在Windows平台上使用任何命令获取最新下载的文件名?

lucene - 通过id的Elasticsearch GET返回所有STORED字段

json - Lucene多重删除查询(JSON)

java - 库重载的方法不用重新编译就可以使用吗?

java - ClassLoader问题导致ClassCastException的解决方法

java - 什么是NullPointerException,我该如何解决?

java - 我可以使用 Lucene 进行业务应用搜索吗?

java - NoClassDefFoundError 静态字段