[英]Hibernate Search 6 with Hibernate 6
我正在尝试使用最新版本从头开始设置 Spring Boot 3.0.1 项目。 到目前为止,我设法开始使用 mvc 和存储库,但是在添加 Hibernate 搜索时,一切都不再有效了。
下面你可以看到我的pom.xml
文件。
当我 go 到“依赖层次结构”(Eclipse STS)时,我可以找到嵌入了hibernate-search-mapper-pojo-base 6.1.7.Final
hibernate-core 5.6.11.Final
嵌入到hibernate-search-mapper-orm 6.1.7.Final
。 这是否意味着我必须手动排除这个并包含更高版本? hibernate-core 5.6.11.Final
还嵌入了hibernate-commons-annotations 5.1.2.Final
。 为什么这么复杂? 有什么我想念的吗?
在控制台日志中我得到这个:
***************************
APPLICATION FAILED TO START
***************************
Description:
An attempt was made to call a method that does not exist. The attempt was made from the following location:
org.hibernate.cfg.annotations.BasicValueBinder.resolveJavaType(BasicValueBinder.java:1002)
The following method did not exist:
'java.lang.reflect.Type org.hibernate.annotations.common.reflection.ReflectionManager.toType(org.hibernate.annotations.common.reflection.XClass)'
The calling method's class, org.hibernate.cfg.annotations.BasicValueBinder, was loaded from the following location:
jar:file:/C:/Users/Hrvoje/.m2/repository/org/hibernate/orm/hibernate-core/6.1.6.Final/hibernate-core-6.1.6.Final.jar!/org/hibernate/cfg/annotations/BasicValueBinder.class
The called method's class, org.hibernate.annotations.common.reflection.ReflectionManager, is available from the following locations:
jar:file:/C:/Users/Hrvoje/.m2/repository/org/hibernate/common/hibernate-commons-annotations/5.1.2.Final/hibernate-commons-annotations-5.1.2.Final.jar!/org/hibernate/annotations/common/reflection/ReflectionManager.class
The called method's class hierarchy was loaded from the following locations:
org.hibernate.annotations.common.reflection.ReflectionManager: file:/C:/Users/Hrvoje/.m2/repository/org/hibernate/common/hibernate-commons-annotations/5.1.2.Final/hibernate-commons-annotations-5.1.2.Final.jar
Action:
Correct the classpath of your application so that it contains compatible versions of the classes org.hibernate.cfg.annotations.BasicValueBinder and org.hibernate.annotations.common.reflection.ReflectionManager
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>3.0.1</version>
<relativePath/> <!-- lookup parent from repository -->
</parent>
<groupId>net.horvoje</groupId>
<artifactId>TheVegCat2</artifactId>
<version>1.0</version>
<packaging>war</packaging>
<name>TheVegCat2</name>
<description>The Vegan Catalog II</description>
<properties>
<java.version>17</java.version>
</properties>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-cache</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-jpa</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-security</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-thymeleaf</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
<dependency>
<groupId>org.thymeleaf.extras</groupId>
<artifactId>thymeleaf-extras-springsecurity6</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-devtools</artifactId>
<scope>runtime</scope>
<optional>true</optional>
</dependency>
<dependency>
<groupId>com.h2database</groupId>
<artifactId>h2</artifactId>
<scope>runtime</scope>
</dependency>
<dependency>
<groupId>com.mysql</groupId>
<artifactId>mysql-connector-j</artifactId>
<scope>runtime</scope>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-configuration-processor</artifactId>
<optional>true</optional>
</dependency>
<dependency>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
<optional>true</optional>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-tomcat</artifactId>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.springframework.security</groupId>
<artifactId>spring-security-test</artifactId>
<scope>test</scope>
</dependency>
<!-- Hibernate Search begin -->
<dependency>
<groupId>org.hibernate.search</groupId>
<artifactId>hibernate-search-mapper-orm</artifactId>
<version>6.1.7.Final</version>
</dependency>
<dependency>
<groupId>org.hibernate.search</groupId>
<artifactId>hibernate-search-backend-lucene</artifactId>
<version>6.1.7.Final</version>
</dependency>
<!-- Hibernate Search end -->
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<configuration>
<excludes>
<exclude>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
</exclude>
</excludes>
</configuration>
</plugin>
</plugins>
</build>
</project>
嗯,看起来 Inte.net 还没有为 Hibernate 6 和 Hibernate Search 6 的新版本做好准备。为了避免这个错误,我不得不删除依赖hibernate-search-mapper-orm
并添加这个: hibernate-search-mapper-orm-orm6
。
当您搜索 maven 存储库并输入“hibernate search orm”时,这个结果是第 10 个结果,我没有看到,因为第 2 名已经没有我写的搜索词。
看起来这个要与 Hibernate 6 一起使用,而且 - 至少对我来说 - 很难找到。
<dependency>
<groupId>org.hibernate.search</groupId>
<artifactId>hibernate-search-mapper-orm-orm6</artifactId>
<version>6.1.7.Final</version>
</dependency>
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.