Spring 引导 2 休眠搜索
Spring Boot 2 Hibernate Search
我正在尝试将我的应用程序迁移到 Spring Boot 2,它使用 Hibernate Search。
我在启动我的应用程序时遇到错误:
- 与 5.5.x.Final :
java.lang.NoSuchFieldError: session
- 与5.6.x.Final或5.8.x.Final:
java.lang.ClassNotFoundException: org.hibernate.search.jpa.Search
- 与5.7.x.Final或5.9.x.Final:
An SPI class of type org.apache.lucene.codecs.Codec with name 'Lucene53' does not exist
- 与 5.10.x.Final :
NoClassDefFoundError: org/hibernate/resource/beans/spi/ManagedBeanRegistry
有关信息,当前 Spring Boot 2.0.3.RELEASE
版本在 5.2.4.Final
中使用 Hibernate 核心依赖项
知道要使用哪个版本吗?
在 Guillaume 回答后更新并深度清理工作区和索引
使用5.9版本,异常进化为No transactional EntityManager available
结语
通过在方法上添加 @Transactional
修复了最后一个错误,但它在没有 Spring Boot 1 的情况下仍然有效。奇怪...
您应该使用的版本取决于所使用的 ORM 版本。检查您的依赖性。
查看此兼容性矩阵:http://hibernate.org/search/releases/#compatibility-matrix
如果您使用的是 Spring Boot 2.0.3 的默认依赖项,则 ORM 的版本应该是 5.2。17.Final 因此您应该使用 Search 5.9。
您还需要使用 Lucene 5。5.x 因此,如果您使用的是旧 Lucene 版本,则可能需要升级 Lucene。
我试图做同样的事情,我在这个存储库中得到了以下结果(有效)
https://github.com/jcangh/boot-hibernate-search
- Spring 引导版本 2.0.9
- Hibernate 搜索 orm 5.7.3.Final
我尝试使用更高版本但没有成功
我正在尝试将我的应用程序迁移到 Spring Boot 2,它使用 Hibernate Search。 我在启动我的应用程序时遇到错误:
- 与 5.5.x.Final :
java.lang.NoSuchFieldError: session
- 与5.6.x.Final或5.8.x.Final:
java.lang.ClassNotFoundException: org.hibernate.search.jpa.Search
- 与5.7.x.Final或5.9.x.Final:
An SPI class of type org.apache.lucene.codecs.Codec with name 'Lucene53' does not exist
- 与 5.10.x.Final :
NoClassDefFoundError: org/hibernate/resource/beans/spi/ManagedBeanRegistry
有关信息,当前 Spring Boot 2.0.3.RELEASE
版本在 5.2.4.Final
知道要使用哪个版本吗?
在 Guillaume 回答后更新并深度清理工作区和索引
使用5.9版本,异常进化为No transactional EntityManager available
结语
通过在方法上添加 @Transactional
修复了最后一个错误,但它在没有 Spring Boot 1 的情况下仍然有效。奇怪...
您应该使用的版本取决于所使用的 ORM 版本。检查您的依赖性。
查看此兼容性矩阵:http://hibernate.org/search/releases/#compatibility-matrix
如果您使用的是 Spring Boot 2.0.3 的默认依赖项,则 ORM 的版本应该是 5.2。17.Final 因此您应该使用 Search 5.9。
您还需要使用 Lucene 5。5.x 因此,如果您使用的是旧 Lucene 版本,则可能需要升级 Lucene。
我试图做同样的事情,我在这个存储库中得到了以下结果(有效)
https://github.com/jcangh/boot-hibernate-search
- Spring 引导版本 2.0.9
- Hibernate 搜索 orm 5.7.3.Final
我尝试使用更高版本但没有成功