使用 Hibernate 6.x 和 Spring Boot 2.7.x 不起作用?

sam*_*ers 9 hibernate jpa spring-data-jpa spring-boot hibernate-6.x

我尝试将 Hibernate Core 6.x 与 Spring Boot / Spring Data JPA 2.7.x 项目一起使用,但它无法获取 Hibernate 6.x 类。

正如您在pom中看到的,在 spring-boot-starter-data-jpa 中,我排除了 hibernate-core 5.6.10-final 并添加了 6.x 作为项目依赖项。

但我看到以下错误:

***************************
APPLICATION FAILED TO START
***************************

Description:

A component required a bean of type 'javax.persistence.EntityManagerFactory' that could not be found.


Action:

Consider defining a bean of type 'javax.persistence.EntityManagerFactory' in your configuration.
Run Code Online (Sandbox Code Playgroud)

我不认为 Spring Boot 会自动配置新的 Hibernate 6.x 版本。

对于 5.6.x,我可以看到以下 11 个 EntityManager 实现。

在此输入图像描述

在迁移到 6.x 时,我只看到一种实现。 在此输入图像描述

发生了什么事,我不知道。有人可以参与并帮助解决这个问题吗?

为什么我想要 6.x ->看看 RIGHT JOIN 在 6.x 中是否有效。即使在其他方面,我认为弄清楚并使这个组合发挥作用将是一项很好的任务。

Mar*_*eel 20

Hibernate 6 使用的 JPA 版本(JPA 3)使用jakarta.persistenceJakartaEE 9 中引入的包名称。Spring Boot 2.x 仍然使用javax.*JakartaEE 8 及更早版本(JPA 2.2 及更早版本)的包命名空间,因此仅支持 Hibernate 5.x (对于 Spring Boot 2.7,Hibernate 5.6.x 是默认值)。

Spring Boot 3 切换到jakarta.*JakartaEE 9+ 的包。因此,您可以升级到 Spring Boot 3 以便能够使用 Hibernate 6。如果您还无法升级 Spring Boot,则需要使用 Hibernate 5.6。