我已导入 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/