【问题标题】:Exception : java.lang.IllegalArgumentException: An SPI class of type org.apache.lucene.codecs.Codec with name 'Lucene410' does not exist异常:java.lang.IllegalArgumentException:不存在名称为“Lucene410”的 org.apache.lucene.codecs.Codec 类型的 SPI 类
【发布时间】:2020-01-14 11:51:20
【问题描述】:

我使用一个多模块 gradle 项目(12 个模块)。我继承了项目,我需要更新其中使用的一些库的版本。

我无法理解这个错误的原因:

    ... 67 more
Caused by: java.lang.IllegalArgumentException: An SPI class of type org.apache.lucene.codecs.Codec with name 'Lucene410' does not exist.  You need to add the corresponding JAR file supporting this SPI to your classpath.  The current classpath supports the following names: [Lucene54]
    at org.apache.lucene.util.NamedSPILoader.lookup(NamedSPILoader.java:114)
    at org.apache.lucene.codecs.Codec.forName(Codec.java:113)
    at org.apache.lucene.index.SegmentInfos.readCodec(SegmentInfos.java:469)
    ... 81 more

最初,项目中显然没有包含对 Lucena 库的依赖。然而,在几个地方有一个直接链接到它的类:

    org.apache.lucene.search.Query lQuery = queryBuilder.keyword().onFields("name", "code").matching(name).createQuery();

我有:

  • IntelliJ IDEA 2019.3.1(社区版)
  • Build #IC-193.5662.53,于 2019 年 12 月 18 日构建
  • 运行时版本:11-ea+121 amd64
  • VM:JetBrains s.r.o 的 OpenJDK 64 位服务器 VM
  • Linux 4.15.0-74-通用
  • GC:ParNew、ConcurrentMarkSweep
  • 内存:1204M
  • 核心数:6

注册表:

  • 非捆绑插件:DBN、Lombook 插件、OdpsStudio、com.jetbrains.ChooseRuntime、marcglasberg.HibernateInspectionsPlugin、org.dnltsk.mapfileplugin、org.jetbrains.kotlin

此库的一个版本在项目树中可见。而不仅仅是核心。

按照hereherehere 的建议,将“org.apache.lucene.codecs.Codec”文件添加到项目中,同时添加显式依赖项(由于某种原因未出现在外部库树)到模块的build.gradle,不提供任何东西。

编辑 1

这个依赖是从 Hibernate 库中获取的:

compile group: 'org.hibernate', name: 'hibernate-search-orm', version: '5.11.4.Final'

如果用旧版本替换新版本,问题就会消失:

compile group: 'org.hibernate', name: 'hibernate-search', version: '5.3.0.Final'

但我想了解如何使用更新的版本。

编辑 2

仅在库版本“5.5.8.Final”(含)之前不会引发此异常。而且,“5.6.6.Final”和更高版本中的任何内容都不会再次出现。

【问题讨论】:

    标签: java hibernate lucene


    【解决方案1】:

    如果您不需要关心存储的索引,您可以简单地删除存储索引的系统文件夹的内容。 <property name="hibernate.search.default.indexBase" value="/var/lucene/indexes"/> 就我而言,它是 /var/lucene/indexes 文件夹

    【讨论】:

      猜你喜欢
      • 2016-11-16
      • 1970-01-01
      • 2013-10-27
      • 2019-04-20
      • 2014-02-04
      • 2020-05-27
      • 1970-01-01
      • 2020-03-05
      相关资源
      最近更新 更多